栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

【PyTorch】torch-geometric 安装

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【PyTorch】torch-geometric 安装

文章目录
  • 1. 查看cuda版本
  • 2. 安装依赖
  • 3. 完成安装
  • 4. 遇到的问题

任务简介:

由于 torch-geometric 的安装需要一定的依赖,所以直接 pip install torch_geometric 安装会出现问题,并且 torch-geometric 的版本需要和 cuda 版本对应。

本文记录 torch-geometric 的正确安装过程。


1. 查看cuda版本

查看安装的pytorch对应的cuda版本,比如 cuda10.2 或 cpu 版本

代码:

import torch
print(torch.version.cuda)

输出:

10.2
2. 安装依赖

根据1.中的对应版本安装以下依赖

pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html

其中,${TORCH} 和 ${CUDA} 分别替换为(1)中确认的版本。

${TORCH} 可选 {1.4.0, 1.5.0, 1.6.0, 1.7.0, 1.8.0}等,PyTorch 1.8.1 选 1.8.0;

${CUDA} 可选 {cpu,cu92,cu101,cu102,cu110};

对应 torch 可设置版本可通过以下链接查看最新版本:

https://pytorch-geometric.com/whl/index.html

假设使用 PyTorch 1.8.1 cu102 版本,安装以上依赖为:

pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.8.0+cu102.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.8.0+cu102.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.8.0+cu102.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.8.0+cu102.html
3. 完成安装

上述依赖安装完成后,torch-geometric 即可正常安装,命令:

pip install torch-geometric
4. 遇到的问题

我使用的是 torch1.8.1,在上述安装完成后,torch-geometric会默认安装 2.0.4版本,2.0.4版本在代码中会出现一些问题,重新安装 torch-geometric 1.7.2 后可正常使用。

以下是 torch1.8.1 对应能正常使用的依赖版本:

安装时加上版本号即可,如:

pip install torch-scatter==2.0.7 -f https://pytorch-geometric.com/whl/torch-1.8.0+cu102.html
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/931867.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号