torch、torch-scatter、torch-sparse版本依赖问题
在安装pprgo(pytorch)环境时,出现torch、torch-scatter、torch-sparse版本不匹配的问题,setup.py如下:
from setuptools import setup
install_requires = [
"numpy",
"scipy>=1.3",
"numba>=0.49",
# "torch",
# "torch-scatter",
# "torch-sparse",
"scikit-learn",
"sacred",
"seml"
]
setup(
name='pprgo_pytorch',
version='1.0',
description='PPRGo model in PyTorch, from "Scaling Graph Neural Networks with Approximate PageRank"',
author='Aleksandar Bojchevski, Johannes Gasteiger, Bryan Perozzi, Amol Kapoor, Martin Blais, Benedek Rózemberczki, Michal Lukasik, Stephan Günnemann',
author_email='a.bojchevski@in.tum.de, j.gasteiger@in.tum.de',
packages=['pprgo'],
install_requires=install_requires,
zip_safe=False
)
手动注释掉torch、torch-scatter、torch-sparse
经过查询发现torch-scatter、torch-spare依赖于torch库,所以必须要版本对应!!!
1.查询cuda版本,下载对应的torch库
linux下输入nvcc- V,返回对应的cuda版本
cuda_version == 10.1
访问pytorc官网https://pytorch.org/
选择想要下载的torch版本,我这里选择的是1.7.0版本
找到torch(1.7.0)、cuda10.1对应的下载命令,此处只需要下载torch,因此输入以下命令
pip install torch==1.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
完成后,查看确认torch版本
2.下载对应版本的torch_scatter、torch_sparse
https://pytorch-geometric.com/whl/
找到对应torch及cuda版本下
torch-1.7.0+cu101版本下对应的有torch_cluster、torch_scatter、torch_sparse、torch_spline_conv四个与之版本依赖的库,cp36代表所对应的python版本为3.6,分别有对应的linux、windows版本
e.g.我的python版本为3.6,torch-1.7.0+cu101,选择对应的torch_scatter、torch_sparse如上图标红框所示。
3.安装.whl文件
命令行中直接:
pip install 下载的whl文件所在路径
(或者切换到下载好的.whl文件目录下直接pip install + 文件名)
完成安装!