安裝PyTorch-Geometric包


pip install torch-scatter
# 報錯
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

解決方法Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)

也可以直接安裝whl包:https://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

CUDA9.1 Visual Studio Integration 安裝失敗問題,如何解決? - 徐遙的回答 - 知乎
https://www.zhihu.com/question/276491276/answer/394778358 (有VS tools的早期版本)

pip install torch-scatter
# 報錯
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include\crt/host_config.h(133): fatal error C1189: #error:  -- unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!
    scatter_kernel.cu
    error: command 'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0\\bin\\nvcc.exe' failed with exit status 2

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include\crt\host_config.h文件中有下面的代碼篩選:

#if _MSC_VER < 1600 || _MSC_VER > 1911

因為安裝的Visual Studio是2019的

// test.cpp
#include <stdio.h>
#include <Windows.h>
int main(){
    printf("%d",_MSC_VER);
    return 0;
}

打開x86_x64 Cross Tools Command Prompt for VS 2019

cl test.cpp # 編譯
test.exe # 輸出版本號1921

修改cuda配置的VS build tools信息好像不管用,使用下面的方法:

1 卸載VS 2019 Build tools

2 安裝VS 2015 Build tools,該工具的_MSC_VER=1900是MS VC++ 14.0

參考visual c++ build tools的安裝與使用中的下載地址

https://download.microsoft.com/download/5/f/7/5f7acaeb-8363-451f-9425-68a90f98b238/visualcppbuildtools_full.exe

$ pip install --verbose --no-cache-dir torch-scatter
$ pip install --verbose --no-cache-dir torch-sparse
$ pip install --verbose --no-cache-dir torch-cluster
$ pip install --verbose --no-cache-dir torch-spline-conv (optional)
$ pip install torch-geometric

如果遇到下面問題:

c:\programdata\anaconda3\include\pyconfig.h(222): fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory

是因為你沒有安裝win10 sdk,參考https://www.jianshu.com/p/a7963ebecbe4

注意pytorch的版本要1.1或者以上,否則torch-scatter會出現安裝錯誤

安裝成功!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM