折腾torch geometric环境

如此不智能不便利不友好的库竟然还有人喜欢用。

记录傻X环境依赖。

https://download.pytorch.org/whl
https://data.pyg.org/whl/

torch1.2.0 torchvision0.4.0 cuda10.0 3.5<=python<=3.7
torch1.3.0 torchvision0.4.1 cuda10.0 3.5<=python<=3.7
torch1.3.1 torchvision0.4.2 cuda10.0 3.5<=python<=3.7
torch1.4.0 torchvision0.5.0 默认cuda10.1(支持10.0) 3.5<=python<=3.8
torch1.5.0 torchvision0.6.0 默认cuda10.1 python>=3.6
torch1.6.0 torchvision0.7.0 默认cuda10.1 python>=3.6
torch1.7.0 torchvision 0.8.0 默认cuda10.2 python>=3.6
torch1.7.1 torchvision0.8.2 默认cuda10.2 python>=3.6

如果装的是cu10.0,只能用torch1.4之前的低版本了。
torch版本太高了会报错

OSError: libcusparse.so.10: cannot open shared object file: No such file or directory

因为torch里面用的是10.1,但我本地是10.0,找不到这个文件。

查询torch里面用的版本

python -c 'import torch; print(torch.__version__)'
python -c 'import torch; print(torch.version.cuda)'

打印结果是

10.1

你看看这个东西,
一个库弄出4个库来。

pip install torch-sparse
pip install torch-scatter
pip install torch-cluster
pip install torch-geometric
pip install torch-spline-conv(optional)

官网

https://pytorch-geometric.com/whl/

装geometric依赖于torch版本。
torch版本决定了torchvision版本。
torchvision版本疑似决定了默认使用的cudatoolkit版本。
所以最终geometric需要跟cuda版本对应。

如果是cuda10.0!只能用torch1.4.0!还要指定cuda版本,不然默认给你装10.1。(21.04.15)

pip install torch==1.4.0+cu100 torchvision==0.5.0+cu100 -f https://download.pytorch.org/whl/torch_stable.html

文件链接

https://download.pytorch.org/whl/cu100/torch-1.4.0%2Bcu100-cp37-cp37m-linux_x86_64.whl
https://download.pytorch.org/whl/cu100/torchvision-0.5.0%2Bcu100-cp37-cp37m-linux_x86_64.whl

配合torch1.4.0+cuda10.0+python3.7装geometric。

https://pytorch-geometric.com/whl/torch-1.4.0+cu100.html

pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.4.0+cu100.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.4.0+cu100.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.4.0+cu100.html
pip install torch-geometric

上面不行就本地安装

wget https://pytorch-geometric.com/whl/torch-1.4.0+cu100/torch_cluster-1.5.4-cp37-cp37m-linux_x86_64.whl
wget https://pytorch-geometric.com/whl/torch-1.4.0+cu100/torch_scatter-2.0.4-cp37-cp37m-linux_x86_64.whl
wget https://pytorch-geometric.com/whl/torch-1.4.0+cu100/torch_sparse-0.6.1-cp37-cp37m-linux_x86_64.whl
pip install *.whl
pip install torch-geometric

配合torch1.7.0+cuda11.0

pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.7.0+cu110.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.7.0+cu110.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.7.0+cu110.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.7.0+cu110.html
pip install torch-geometric

卸载

pip uninstall torch-scatter
pip uninstall torch-sparse
pip uninstall torch-cluster
pip uninstall torch-spline-conv
pip uninstall torch-geometric

其他版本

跑geometric的开源项目,经常离不开ogb数据包。
截止21.04最新的ogb包是1.3.1版本的。
然而ogb==1.3.1要求torch>=1.6.0
所以我们为了适配cuda10.0,torch1.4.0。
只能降格使用ogb==1.2.0,(torch>=1.2.0)

如果还要用dgl库(目前最前0.6.1)
推荐降格使用dgl==0.4.3

补充
遇到nvcc执行失败

vim ~/.bashrc

修改

export CUDA_HOME=/usr/local/cuda

export PATH="/usr/local/cuda-10.0/bin:$PATH"  
export LD_LIBRARY_PATH="/usr/local/cuda-10.0/lib64:$LD_LIBRARY_PATH"

中间文件夹的名字跟cuda版本对应。
参考的是官方提供的解决方案

https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html#installation-via-binaries

更新 cuda10.2 + torch1.9.0 + pyg2.0.2

python==3.7.9

pip install torch-sparse -f https://data.pyg.org/whl/torch-1.10.0%2Bcu102/torch_sparse-0.6.12-cp37-cp37m-linux_x86_64.whl
pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0%2Bcu102/torch_scatter-2.0.9-cp37-cp37m-linux_x86_64.whl
pip install torch-cluster -f https://data.pyg.org/whl/torch-1.10.0%2Bcu102/torch_cluster-1.5.9-cp37-cp37m-linux_x86_64.whl

更新 cuda11.1 + torch1.9.0 + pyg2.0.3

python==3.9.7

pip install torch==1.9.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
pip install torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
pip install torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

pip install torch-geometric==2.0.3
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.9.0%2Bcu111.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.9.0%2Bcu111.html
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0%2Bcu111.html

更新 cuda11.3 + torch 1.11.0+ pyg2.0.4

python=3.9.7

https://download.pytorch.org/whl/cu113/torch-1.11.0%2Bcu113-cp39-cp39-linux_x86_64.whl

有两个源路径

https://pytorch-geometric.com/whl/torch-1.11.0%2Bcu113.html
https://pytorch-geometric.com/whl/torch-1.11.0%2Bcu115.html

pip install torch-geometric==2.0.4
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.11.0%2Bcu113.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.11.0%2Bcu113.html
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.11.0%2Bcu113.html

对cuda10.2 ,用torch1.11 + pyg2.0.4+ torch-sparse0.6.13有问题。
import torch_geometric.nn 会报 segmentfault
回退
torch 1.10.2
torch-geometric 2.0.3
torch-scatter 2.0.9
torch-sparse 0.6.12
torch-cluster 1.5.9

更新 cuda11.6+torch 1.12.1+pyg2.3.1

python ==3.10

pip install torch-geometric==2.3.1
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://pytorch-geometric.com/whl/torch-1.12.1%2Bcu116.html

更新 cuda11.7+torch1.13.1+pyg2.3.1

python==3.10。(230521)

pyg库里,torch==1.12.1只支持到cuda11.6。
必须更新到 torch==1.13.0及以上才能支持cuda11.7。
而pyg_lib最高只支持到python==3.10,不能装3.11。

pip install torch_geometric
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-1.13.1+cu117.html

哦吼。看到官方说明。

From PyG 2.3 onwards, you can install and use PyG without any external library required except for PyTorch. For this, simply run:
pip install torch_geometric
PyG 2.3 requires that at least PyTorch 1.12 is installed.

torch 1.12 + pyg 2.3 可以不用额外包了。
开源多年工程总算有长进了。

更新 cuda11.7+torch2.0.1+pyg2.3.1

python==3.10.0 + torchvision==0.15.2
这个版本卡的很死。
torchvision只能0.15.2,torch只能2.0.1

pip install torch_cluster torch_scatter torch_sparse -f https://data.pyg.org/whl/torch-2.0.1%2Bcu117.html

更新 cuda11.8+torch2.1.0+pyg2.4.0

python==3.11.0 (23.11.28)
说好的装pyg就不用装附属库呢。。

pip install torch_geometric==2.4.0
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.1.0+cu118.html

pip install https://data.pyg.org/whl/torch-2.1.0%2Bcu118/torch_cluster-1.6.2%2Bpt21cu118-cp310-cp310-linux_x86_64.whl

更新 cuda11.8+torch2.2.1+pyg_lib0.4.0

python>=3.10.0 (24.4.4)

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.2.1+cu118.html

  • 7
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值