- 创建新的虚拟环境
conda create -n py37 python=3.7
- 进入虚拟环境
conda activate py37
- 查看本机的cuda版本以及python版本
/usr/local/cuda/bin/nvcc -V
python
- 从官网下载对应版本的torch和torchvision安装包
https://download.pytorch.org/whl/torch_stable.html
注意:此处torch和torchvision的版本也要相互对应,对应查看此网址:
https://blog.csdn.net/AugustMe/article/details/109028989 - 进入安装包所在的目录
cd /home/xxxx(usr_name)/cu101
- 安装torch和torchvision,查看torch.version.cuda版本是否与nvcc的版本相同
pip install torch-1.5.1+cu101-cp37-cp37m-linux_x86_64.whl
pip install torchvision-0.6.1+cu101-cp37-cp37m-linux_x86_64.whl
python -c "import torch; print(torch.version.cuda)"
python -c "import torch; print(torch.__version__)"
- pip install安装torch-geometric所需要的对应版本的依赖包以及torch-geometric
pip install --no-index torch_scatter -f https://pytorch-geometric.com/whl/torch-1.5.0+cu101.html
pip install --no-index torch_sparse -f https://pytorch-geometric.com/whl/torch-1.5.0+cu101.html
pip install --no-index torch_cluster -f https://pytorch-geometric.com/whl/torch-1.5.0+cu101.html
pip install --no-index torch_spline_conv -f https://pytorch-geometric.com/whl/torch-1.5.0+cu101.html
pip install torch-geometric==1.5.0
- pip list可以看出我们所安装的包都安装成功
- python 之后import可以看出导入成功,到此安装成功,如果未安装成功,可以尝试删除此虚拟环境,create一个新的进行再次尝试
参考链接:
https://blog.csdn.net/qq_40329272/article/details/111801695
https://github.com/rusty1s/pytorch_geometric/issues/999
pytorch-geometric的官方链接,希望对大家有用
https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html