No module named ‘torch_geometric‘解决办法——PyG(PyTorch Geometric)安装教程

1、查询已安装的torch版本

一定要先查询自己的torch版本,也不同版本的依赖跟库都是不一样的。

import torch
print("torch版本:",torch.__version__)

输出结果:
在这里插入图片描述

2、安装依赖

2.1 进入官网下载依赖。

官网下载链接:官网下载链接,进入官网找到自己对应的版本;
在这里插入图片描述

这里要仔细看清楚,一共需要下载四个依赖包,根据自己的Python版本(cp39表示的就是Python3.9)以及系统版本(win、macos、linux)来选择。
在这里插入图片描述

下载完之后的包总共有四个,如下图:
在这里插入图片描述

2.2 安装依赖

找到下载依赖的文件夹,使用cmd窗口,直接输入 pip install + 包全名
例如安装第一个包的命令:pip install torch_cluster-1.6.1+pt113cpu-cp39-cp39-win_amd64.whl
将4个包都安装完成之后,进入到最后一步。

2.3 安装geometric

同样在上一步的cmd窗口中,输入以下代码:pip install torch-geometric
显示安装成功。
在这里插入图片描述

  • 10
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
### 回答1: 要安装 PyTorch Geometric,可以按照以下步骤进行: 1. 安装 PyTorch 在安装 PyTorch Geometric 之前,您需要先安装 PyTorch。您可以使用以下命令在命令行中安装最新版本的 PyTorch: ``` pip install torch ``` 请注意,您需要确保您已安装与您的操作系统和 Python 版本兼容的 PyTorch 版本。有关更多详细信息,请参阅 PyTorch 官方网站。 2. 安装 PyTorch Geometric 要安装 PyTorch Geometric,您可以使用以下命令: ``` pip install torch-geometric ``` 此命令将自动下载并安装 PyTorch Geometric 及其所有依赖项。请注意,安装可能需要一些时间,具体取决于您的计算机性能和网络连接速度。 3. 验证安装 要验证您是否已成功安装 PyTorch Geometric,您可以在 Python 中导入该库并查看其版本号: ``` import torch_geometric print(torch_geometric.__version__) ``` 如果您看到了 PyTorch Geometric 的版本号,则说明您已成功安装该库。 ### 回答2: PyTorch Geometric是一个基于PyTorch的几何深度学习库,提供各种处理图和几何数据的工具。安装PyTorch Geometric需要以下步骤: 1. 安装PyTorch:在安装PyTorch之前,需要确定所使用的CUDA和cuDNN版本。可以从PyTorch官网上下载相应的版本,也可以通过pip安装:pip install torch。 2. 安装PyTorch Geometric依赖PyTorch Geometric库的安装依赖一些软件括numpy、scipy、networkx等。可以通过pip安装依赖:pip install -r requirements.txt。 3. 安装PyTorch Geometric:可以通过pip安装PyTorch Geometric:pip install torch-geometric。如果使用的是开发版本,则可以通过git从GitHub上下载:git clone https://github.com/rusty1s/pytorch_geometric.git。 4. 验证PyTorch Geometric的安装:可以进入Python交互环境,导入torch-geometric库,验证是否正确安装:import torch-geometric as tgm。 在安装过程中,需要注意一些常见的问题: 1. PyTorch的版本和CUDA/cuDNN的版本需要匹配,否则会出现兼容性问题; 2. 如果已经安装了PyTorch和其依赖的软件,再次安装时需使用--upgrade选项,避免出现安装重复问题; 3. 在Windows系统下,由于PyTorch Geometric使用PyTorch的扩展功能,需要使用Microsoft Visual C++ Redistributable for Visual Studio 2015、2017、2019; 4. 在使用GPU加速时,需要确认显卡所支持的CUDA版本是否与安装的PyTorch版本匹配。 总之,安装PyTorch Geometric需要按照一定的步骤进行,需要注意软件依赖关系和系统的兼容性,只有在正确安装之后才能使用其提供的各种工具和函数。 ### 回答3: PyTorch Geometric是一种基于PyTorchGeometric深度学习库,它专门用于处理图形和进化的深度学习问题。它的设计旨在简化图形处理任务,其功能括通过内置的图形卷积运算,实现对节点属性和图形跨边界通信的直接处理。接下来,本文将介绍如何安装PyTorch Geometric。 1.安装PyTorch 在开始安装PyTorch Geometric之前,必须先安装PyTorch,可以使用conda或pip进行安装。例如,这是使用pip安装PyTorch的命令: pip install torch torchvision 2.安装PyTorch Geometric 有两种不同的方式可以安装PyTorch Geometric。第一种是使用pip,通过以下命令即可完成安装: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+cpu.html pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.9.0+cpu.html pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.9.0+cpu.html pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.9.0+cpu.html pip install torch-geometric 第二种方式是在Anaconda环境下使用conda进行安装。通过以下命令安装: conda install pytorch-geometric -c rusty1s -c conda-forge 3.测试安装 完成上述步骤后,可以通过在Python交互界面或其他Python环境中运行以下代码,来测试PyTorch Geometric是否已成功安装: import torch import torch_geometric print(torch.__version__) print(torch_geometric.__version__) 如果能够顺利输出torchtorch_geometric的版本号,则说明安装成功。 总的来说,安装PyTorch Geometric需要先安装PyTorch,然后使用pip或conda进行安装,最后进行测试。在安装过程中,需要注意PyTorchPyTorch Geometric的版本对应关系。
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值