由于我自己也下了好几次这几个包,所以我自己也写篇文章,亲测有效。(期间真的是太痛苦了)
首先我们需要知道torch-scatter,torch-sparse,torch-cluster,torch-spline-conv等库的安装是需要与torch和cuda版本对应的,所以这就是为什么通常直接安装后不可以用的原因。
1.查看你的torch和cuda版本
import torch
print(torch.__version__)
print(torch.version.cuda)
2.安装:
参考官网:Installation — pytorch_geometric documentationhttps://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html可以直接用如下命令:
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
其中 {TORCH} 替 换 为 torch 的 版 本 号 ,{CUDA} 替换为上面查询得到的cuda版本号。例如我的是torch 1.13.0 和 cuda11.7,我使用的安装命令如下:
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.13.0+cu117.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.13.0+cu117.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.13.0+cu117.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.13.0+cu117.html
3.如果失败了
要么是没对应上版本,要么就是存在残存的文件。建议完全卸载后再重新安装。