最近用到这两个库,安装过程遇到不少问题,记录一下安装过程。
首先,成功安装版本例子:python3.7 + CUDA11.3 + pytorch1.10.1-GPU版 + torch-geometric2.0.0(划重点) + 对应版本的依赖包(详见此网址)+torch-geometric-temporal 0.54.0
1.首先安装Anaconda,不再赘述。
2.创建并激活虚拟环境
conda create -n torch-geo python=3.7
activate torch-geo
3.安装CUDA和cudnn,以及pytorch,参考cuda安装,torch安装以及版本对应
4.在安装torch-geometric之前需先装其依赖包,进入
https://pytorch-geometric.com/whl
查看自己对应版本,我选择的是 torch-1.10.1+cu113,因为我是win10系统,所以选择:
https://data.pyg.org/whl/torch-1.10.0%2Bcu113/torch_cluster-1.6.0-cp37-cp37m-win_amd64.whl
https://data.pyg.org/whl/torch-1.10.0%2Bcu113/torch_scatter-2.0.9-cp37-cp37m-win_amd64.whl
https://data.pyg.org/whl/torch-1.10.0%2Bcu113/torch_sparse-0.6.13-cp37-cp37m-win_amd64.whl
https://data.pyg.org/whl/torch-1.10.0%2Bcu113/torch_spline_conv-1.2.1-cp37-cp37m-win_amd64.whl
这几个版本的包。
5.安装torch-geometric,直接pip install torch-geometric会在import时报错,后在官网查看了一下,
You can now install PyG via Anaconda for all major OS, PyTorch and CUDA combinations 🤗 If you have not yet installed PyTorch, install it via conda
as described in its official documentation. Given that you have PyTorch installed (>=1.12.0
), simply run
及直接pip的torch-geometric是2.3.0版本,只支持torch1.12.0及以上版本,因此安装时需指定更低的版本才行,可以在 torch-geometric · PyP I找
我选择了2.0,但安装torch-geometric时报错:Could not find a version that satisfies the requirement rdflib 找不到rdflib包,所以先装rdflib再装torch-geometric
pip install rdflib
pip install torch-geometric==2.0.0
安装后不再报错。
6.pip安装matplotlib时报错ERROR: Could not find a version that satisfies the requirement matplotlib (from versions: none),采用豆瓣源安装成功
pip install xxx -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
7.安装torch-geometric-temporal,需要几个依赖参考此链接。到这步完成基本就成功了,import 各个包试一下,不报错即可。