今天真的是吐血,一定要把這個分享出去,讓更多的人少走彎路。很少有人分享torch-scatter -cluster -spline -geometric 安裝,找淘寶店給我安裝,他竟然說不會!我隻能自己尋找方法了!
首先,相信很多人看過這個教程:https://github.com/rusty1s/pytorch_geometric#pytorch-170

我來排一排這個教程的坑,就可以安裝成功了。
一、環境變量切換
一定要切換到想要安裝庫的環境變量中
conda env list # 檢視變量清單
activate 變量名 # 激活要安裝庫的變量
二、pytorch版本的選擇
如果打開下載下傳位址的上一級目錄:https://pytorch-geometric.com/whl/,可以看到pytorch版本(注:沒有1.7.1或1.6.**等版本的安裝連結,如果已安裝的pytorch是1.7.**版本,安裝連結和1.7.0一樣)
三、cuda的選擇
與電腦已安裝版本對應,檢視版本後,再選擇安裝連結。
另,以cu101為例,教程中 “${CUDA}” 改為 ”cu101“,
我确定Cuda版本的方法是:用everything軟體搜尋“cuda”關鍵字,在anaconda安裝目錄下發現如下圖所示檔案夾,進而确定cuda版本
題外話:
everything是一個非常友善且高效的檔案搜尋小工具,安裝包可自取
連結:https://pan.baidu.com/s/18r4NGTTbchrKvBCM7bjxKA
提取碼:vqja
四、安裝的完成指令
則完整指令為(以Python3.7、pytorch1.7.1、cuda101為例):
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.7.0+cu101.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.7.0+cu101.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.7.0+cu101.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.7.0+cu101.html
pip install torch-geometric
五、安裝完成測試
在cmd中,進入python環境:
(py37) C:\Users\xiaozhe>python
Python 3.7.9 (default, Aug 31 2020, 17:10:11) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
倒入庫(注:庫的名字中“-”改為下劃線“_"才能成功導入):
>>> import torch_scatter
>>> import torch_sparse
>>> import torch_cluster
>>> import torch_spline_conv
>>> import torch_geometric
不報錯就成功了 !