官方文檔:https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html
按照官方文檔,確保cuda和nvcc版本一致
$ python -c "import torch; print(torch.version.cuda)" >>> 10.0 $ nvcc --version >>> 10.0
我的運行如下所示:
$ python -c "import torch; print(torch.version.cuda)" >>>9.2 $ nvcc --version >>>nvcc: NVIDIA (R) Cuda compiler driver >>>Copyright (c) 2005-2017 NVIDIA Corporation >>>Built on Fri_Sep__1_21:08:03_CDT_2017 >>>Cuda compilation tools, release 9.0, V9.0.176
然后安裝依賴,官方文檔中:
依賴網址:https://pytorch-geometric.com/whl/torch-1.4.0.html
由於我的服務器上無法登陸這個網站,所以我下載到自己電腦本地,然后文件傳到服務器上進行本地安裝,有條件的可以直接運行官方指南的代碼,進行線上下載。
我應用的版本:cuda9.2,pytorch1.4
依賴放到了百度雲上
鏈接:https://pan.baidu.com/s/1cnClAitoKeGtn4sJQBQXAw
提取碼:zfl9
本地pip install就行了
最后一步
$ pip install torch_geometric
看一下有沒有成功~
$ python -c "import torch_geometric; print(torch_geometric.__version__)" >>>1.4.3
Colab上
colab上的cuda 版本是10.1,按照官方文檔配置會報錯依賴包版本不匹配,把命令更改為以下:
!pip install torch-scatter==latest+cu101 torch-sparse==latest+cu101 torch-cluster==latest+cu101 -f https://s3.eu-central-1.amazonaws.com/pytorch-geometric.com/whl/torch-1.4.0.html
!pip install torch-geometric
使用愉快