linux和colab上安装torch_geometric踩坑记录,安装过程

官方文档: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

使用愉快

原文地址:https://www.cnblogs.com/GoubuLi/p/12624277.html