目录

PyTorch Geometric简介

安装PyTorch Geometric


PyTorch Geometric简介

官方网站:PyG Documentation — pytorch_geometric documentation (pytorch-geometric.readthedocs.io)

PyTorch Geometric 中设计了一种新的表示图数据的存储结构,也是 PyTorch Geometric中实现的各种方法的基本数据形式,可以轻松地使用GCN网络进行训练。

安装PyTorch Geometric

注意:由于自动pip安装PyTorch-Geometric的依赖库很容易导致失败,故本文采用了手动安装的方式。

1、首先在CMD控制平台查看自己电脑python、torch、CUDA的各个版本。

>>>python
>>>import torch

>>>print(torch.cuda.is_available()) # 查看CUDA是否可用
>>>print(torch.cuda.device_count()) # 查看可用的CUDA数量
>>>print(torch.version.cuda) # 查看CUDA的版本号

>>>torch.__version__

可以看出我的python版本是3.9,torch版本是1.9.0,CUDA版本是10.2 。

2、打开下面的连接Pytorch官方链接:点击链接打开官方下载文件包网页

3、(重要)根据第一步的torch版本选择对应的链接,比如我电脑已经下载好的torch版本是1.9.0,CUDA版本对应的是10.2,那么对应就是点击对应的链接是“torch-1.9.0+cu102”

4、本人的电脑操作系统是Windows和Python的版本是3.9.0,所以选择对应的whl文件分别点击进行下载,下载到自己能找到的位置即可。(注意:cp39m对应3.9.0,win对应Windows,amd64对应64位) 

 中总共包含4总类型的文件,分别找到并下载:

torch_cluster-1.5.9-cp39-cp39-win_amd64.whl

torch_scatter-2.0.9-cp39-cp39-win_amd64.whl

torch_sparse-0.6.12-cp39-cp39-win_amd64.whl

torch_spline_conv-1.2.1-cp39-cp39-win_amd64.whl

5、下载好文件后将这些whl文件复制粘贴到python39中的Scripts文件夹中,方便后面使用pip进行安装。

 6、在搜索栏输入cmd,在文件路径打开cmd:

7、依次复制下面的命令在CMD控制平台中的D:\python3.9\Scripts>路径中运行。

pip install torch_cluster-1.5.9-cp39-cp39-win_amd64.whl

pip install torch_scatter-2.0.9-cp39-cp39-win_amd64.whl

pip install torch_sparse-0.6.12-cp39-cp39-win_amd64.whl

pip install torch_spline_conv-1.2.1-cp39-cp39-win_amd64.whl

pip install torch-geometric

 8、验证是否安装成功,输入下面的命令在CMD平台运行,没有报错说明安装导入包torch_geometric成功。

python -c "import torch_geometric"

至此就安装完成啦,下一篇文章将会介绍其基本用法~ 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐