正确安装 torch_geometric库
step1: 查看pytorch+cuda 版本
torch-scatter torch-sparse torch-cluster torch-spline-conv 这些关联包要与torch版本匹配。
import torch
print(torch.__version__)
print(torch.cuda.is_available())
torch.version.cuda
或者 pip list查看版本
step2: 下载对应版本的包文件
比如我的是1.13.0,cu117版本,那么我就装1.13.0 cu117版本对应的那四个关联包,如下命令:
对应版本下载链接:https://data.pyg.org/whl/
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
pip install torch-geometric
step3: 注意torch-geometric的安装
若报错:AttributeError: module ‘torch_geometric.utils‘ has no attribute ‘scatter_‘
直接搜这个错误,没有找到相关的内容,大多数解决方案是对于pytorch出现的报错,应该是用这个库的人不多。在Github上torch-geometric库的讨论区中也没有找到相关的内容。抱着试一试的心态,我直接搜这个函数*torch_geometric.utils.scatter_*的相关内容。在一篇介绍torch-geometric安装的博文中,我找到了一句关于torch-geometric版本的说明,举例介绍了“torch_geometric.utils.scatter_这个方法,在1.5及以后的版本就不支持了,所以代码中有用到这个方法的,要不就另写一个函数代替,要不就把版本退到1.4.3”。于是我尝试把torch-geometric退回到1.4.3版本:
pip install torch-geometric==1.4.3
step4: 遇到的其他奇葩问题
OSError: Could not load shared object file: llvmlite.dll
pip 卸载: numba 和 llvmlite 包
然后: pip 安装
有人建议使用conda 安装,(慢且安装与其他的包冲突)本人未成功。改用pip 成功了!!!!
pip uninstall numba llvmlite
pip install numba llvmlite
step5: 参考
————————————————
参考链接:llvmlite.dll 错误解决
参考链接[1] torch-geometric 版本:https://blog.csdn.net/qq_40329272/article/details/111807624
参考链接[2] :https://blog.csdn.net/qq_46031119/article/details/128153390