Win10下PyTorch-Geometric(PyG)安装教程

PyG (即PyTorch-geometric)是德国多特蒙德工业大学的研究者们提出的一个基于Pytorch的拓展库,为各种复杂的图神经网络封装好了一个统一的规范接口,为我们搭建自己设计的图神经网络提供了便利,其地址https://github.com/pyg-team/pytorch_geometric
1、基础环境
操作系统:Win10
Cuda版本:Cuda 10.1
Pytorch版本:Pytorch 1.4
Python版本:Python 3.7
通过以下方法安装容易出错:

pip install torch-scatter -f https://data.pyg.org/whl/torch-1.11.0+${
    
    CUDA}.html
pip install torch-sparse -f https://data.pyg.org/whl/torch-1.11.0+${
    
    CUDA}.html
pip install torch-geometric

2、首先下载依赖包,下载地址:https://data.pyg.org/whl/里面包含各个版本的pytorch
基于我的torch1.4进入https://pytorch-geometric.com/whl/torch-1.4.0.html
需要分别下载以下四个.whl(均为GPU版本)
torch_cluster-latest+cu101-cp37-cp37m-win_amd64.whl
torch_scatter-latest+cu101-cp37-cp37m-win_amd64.whl
torch_sparse-latest+cu101-cp37-cp37m-win_amd64.whl
torch_spline_conv-latest+cu101-cp37-cp37m-win_amd64.whl
这里的cu101指的是cuda的版本10.1,cp指的是python版本,37指的是python=3.7。需要根据自己相应的版本下载依赖包,如果版本不匹配,可能会在执行安装命令时出现
xx.whl is not a supported wheel on this platform

3、安装
打开命令行,在这里打开Anaconda prompt切换到以上四个下载好的目录,我的四个.whl文件在e盘下。
在这里插入图片描述
在自己的虚拟环境下分别执行安装命令:

pip install torch_cluster-latest+cu101-cp37-cp37m-win_amd64.whl
pip install torch_scatter-latest+cu101-cp37-cp37m-win_amd64.whl
pip install torch_sparse-latest+cu101-cp37-cp37m-win_amd64.whl
pip install torch_spline_conv-latest+cu101-cp37-cp37m-win_amd64.whl
pip install torch-geometric=1.4.3 # 指定安装的版本1.4.3

4、测试

import torch_geometric.transforms as T
from torch_geometric.nn import GCNConv,ChebConv

猜你喜欢

转载自blog.csdn.net/qq_36455412/article/details/125594763