算法conda环境torch-geometric安装
操作系统为centos 7,PyTorch环境需要glibc>=v2.17
pytorch官网地址:https://pytorch.org/get-started/previous-versions/
torch-geometric官网地址:https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html
安装之前查看操作系统支持的glibc版本,v1.11.x,v1.10.x,v1.9.x需要glibc=2.27
strings /lib64/libm.so.6 | grep GLIBC_
方式一:安装PyTorch(v1.11.x,v1.10.x,v1.9.x)
注意:这两个版本需要glibc=v2.27版本,这里选择不安装附加包 torch-spline-conv,跳过后面glibc报错
1.创建conda虚拟环境
conda create -n test1 python=3.9
2. 安装PyTorch环境
这里直接选择安装最新版本的pytorch,cudatoolkit版本对应显卡版本
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
3.安装 torch-geometric
此处选择Anaconda方式进行安装
conda install pyg -c pyg
安装完成后,执行如下操作
$ conda list |grep torch
$ pip list | grep torch
torch 1.11.0
torch-cluster 1.6.0
torch-geometric 2.0.4
torch-scatter 2.0.9
torch-sparse 0.6.13
torchaudio 0.11.0
torchmetrics 0.9.1
torchvision 0.12.0
卸载torch-spline-conv包
$ pip uninstall torch-spline-conv
4.测试
$ python
>> from torch.nn import Linear, ReLU
>> from torch_geometric.nn import Sequential, GCNConv
上述问题无报错即可
出现如下报错,则是因为 torch-spline-conv 附加包导致,若此依赖包没有使用卸载即可
方式二:安装PyTorch(v1.8)版本,无外网
注意:此版本无需操作系统支持高版本的GLIBC_2.27
1.创建conda虚拟环境
conda create -n test1 python=3.9
2. 安装PyTorchv1.8
cudatoolkit版本对应显卡版本
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=10.2 -c pytorch
3.安装 torch-geometric
此处使用“Installation via Anaconda“安装,操作失败。选择使用“Installation via Pip Wheels”安装
- 查看pytorch、cuda版本
python -c "import torch; print(torch.__version__)"
>>> 1.8.0
python -c "import torch; print(torch.version.cuda)"
>>> 10.2
- 访问安装包地址,替换对应版本,下载包(torch-scatter、torch-sparse 、torch-cluster、torch-spline-conv)
${TORCH}==1.8.0
${CUDA}==10.2
https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html
https://data.pyg.org/whl/torch-1.8.0+cu102.html
- 将4个包上传到对应服务器
pip install torch_*
pip install torch-geometric
4.测试
$ python
>> from torch.nn import Linear, ReLU
>> from torch_geometric.nn import Sequential, GCNConv
ic
##### 4.测试
$ python
from torch.nn import Linear, ReLU
from torch_geometric.nn import Sequential, GCNConv
上述问题无报错即可