首页 > 编程语言 >python安装torch-cluster、torch-scatter、torch-sparse和torch-geometric | torch_geometric详细安装教程

python安装torch-cluster、torch-scatter、torch-sparse和torch-geometric | torch_geometric详细安装教程

时间:2024-08-06 14:27:07浏览次数:16  
标签:torch cuda install pip geometric 安装 cp310

1.检查CUDA版本

【方法1】用nvidia-smi

已装cuda,用nvidia-sminvcc -V 查看
在这里插入图片描述

【方法2】用torch

已装torch,用torch代码打印

import torch
print(torch.__version__)                # 查看pytorch安装的版本号
print(torch.cuda.is_available())        # 查看cuda是否可用。True为可用,即是gpu版本pytorch
print(torch.cuda.get_device_name(0))    # 返回GPU型号
print(torch.cuda.device_count())        # 返回可以用的cuda(GPU)数量,0代表一个
print(torch.version.cuda)               # 查看cuda的版本

在这里插入图片描述

2.安装torch(已装请跳过)

pip安装请看: https://download.pytorch.org/whl/torch_stable.html
找到自己系统环境+cuda版本+py版本 对应的torch轮子
我的是cu117/torch-1.13.1%2Bcu117-cp310-cp310-linux_x86_64.whl

  • 【安装方法】 下载安装(Linux可以用wget安装 / windows可以点击下载到本地)
    pip install whl的完整路径
pip install https://download.pytorch.org/whl/torch_stable.htmlcu117/torch-1.13.1%2Bcu117-cp310-cp310-linux_x86_64.whl

在这里插入图片描述

3.安装torch-geometric

去到网站:https://pytorch-geometric.com/whl/index.html
在这里插入图片描述

  • 【安装方法1】 :pip install -f 指定网址(带torch和cuda版本的网址)
    逐个包指定网址,也可以全部的包,一起指定网址
    pip install torch-scatter torch-sparse torch-spline-conv torch-cluster torch-geometric -f https://pytorch-geometric.com/whl/torch-1.13.1%2Bcu117.html
    
  • 【安装方法2】 :下载后,再逐个pip(按顺序)
    • torch_scatter
    pip install torch_scatter-2.1.0+pt113cu117-cp310-cp310-linux_x86_64.whl
    
    • torch_sparse
    pip install torch_sparse-0.6.17+pt113cu117-cp310-cp310-linux_x86_64.whl
    
    • 再到 torch_cluster
    pip install torch_cluster-1.6.1+pt113cu117-cp310-cp310-linux_x86_64.whl
    
    • 然后到 torch_cluster
    pip install torch_spline_conv-1.2.1+pt113cu117-cp310-cp310-linux_x86_64.whl
    
    • 最后到 torch_geometric(需关闭机场)
    pip install torch_geometric==2.0.4 -i https://pypi.doubanio.com/simple
    或者
    pip install torch_geometric -i https://mirrors.aliyun.com/pypi/simple
    或者
    pip install torch_geometric -i https://pypi.tuna.tsinghua.edu.cn/simple
    
  • 检验是否安装成功
    • import torch_geometric 一下未报错即可
      在这里插入图片描述

4.常见错误

错误1. RuntimeError

RuntimeError: Detected that PyTorch and torch_scatter were compiled with different CUDA versions. PyTorch has CUDA version 10.2 and torch_scatter has CUDA version 11.3. Please reinstall the torch_scatter that matches your PyTorch install.

  • 【解决方案】:检查torch版本 + CUDA版本 + py版本,和 torch-geometric相关包的版本,是否一致。

.

错误2. An issue occurred xx

UserWarning: An issue occurred while importing ‘torch-scatter’. xxxxxxxx torch_scatter/_scatter_cuda.so: undefined symbol: _ZNK3c107SymBool10guard_boolEPKcl

UserWarning: An issue occurred while importing ‘torch-cluster’. xxxxxxxx
torch_cluster/_grid_cuda.so: undefined symbol: _ZNK3c107SymBool10guard_boolEPKcl

UserWarning: An issue occurred while importing 'torch-spline-conv’.
torch_spline_conv/_basis_cuda.so: undefined symbol: _ZNK3c107SymBool10guard_boolEPKcl

UserWarning: An issue occurred while importing ‘torch-sparse’.
torch_sparse/_diag_cuda.so: undefined symbol: _ZN3c106detail19maybe_wrap_dim_slowIlEET_S2_S2_b

  • 【解决方案】:卸载torch-geometric相关4个包,再按顺序 依次安装
    pip uninstall torch-cluster
    pip uninstall torch-scatter
    pip uninstall torch-sparse
    pip uninstall torch-geometric
    

标签:torch,cuda,install,pip,geometric,安装,cp310
From: https://blog.csdn.net/sinat_29950703/article/details/140911306

相关文章

  • 解决torchaudio.load报错 (Couldn't find appropriate backend to handle uri )
    解决torchaudio.load报错(Couldn'tfindappropriatebackendtohandleuri)问题描述(报错信息):问题:Traceback(mostrecentcalllast): File"resample.py",line43,in<module>  resample_use_cuda() File"resample.py",line24,inres......
  • Dreamweaver (DW)2021 下载 安装
    将 Dreamweaver2021 压缩包解压到本地:点击蓝色字体下载压缩包提取码ixsu鼠标右键点击 Set-up 选择 以管理员身份运行:点击 更改位置 可以自定义选择安装路径 也可以选择默认位置点击 继续:等待安装正常等待5分钟左右:安装完成点击关闭:双击桌面 Drea......
  • pytorch OSError: [WinError 1114] 动态链接库(DLL)初始化例程失败”原因分析
    动态链接库失败“OSError:[WinError1114]动态链接库(DLL)初始化例程失败。Errorloading"cublas64_12.dll"oroneofitsdependencies”原因分析出错情况:在importtorch中直接被抛出异常环境探讨【问题复现】:因为使用了新的torch-gpu环境【name称为torch】,固怀疑......
  • kubernetes二进制安装 -- 1.30.3
    1、节点规划10.202.99.34master0110.202.99.35master0210.202.99.36master0310.202.99.37node0110.202.99.100vip2、环境准备2.1、关闭防火墙、selinux、swap和NetworkManager#关闭selinux##临时关闭setenforce0##永久关闭sed-i's/enforcing/disabl......
  • Ubuntu 24.04 LTS Linux上安装Azure Data Studio
    AzureDataStudio是由Microsoft开发的开源数据库管理和开发工具。它是一种跨平台数据库管理工具,可在所有流行的操作系统(Windows、macOS和Linux)上运行。该软件提供了一个现代编辑器和丰富的界面,用于管理各种数据库系统,例如MicrosoftSQLServer、PostgreSQL等。它还为......
  • Ubuntu 24.04 LTS Noble安装OpenSSH服务器
    OpenSSH服务器在 UbuntuLinux上提供安全外壳(SSH)协议,以便远程管理系统,同时提供高级别的加密,确保安全。虽然许多Linux系统默认配备OpenSSH服务器,但在Ubuntu24.04上,我们必须手动安装它。因此,在本教程中,我们将介绍在Ubuntu24.04系统上安装和配置OpenSSH服务......
  • .NET6 独立模式部署应用程序(无需客户机安装指定版本.NET运行时)
    下图对于.NET开发人员一定不陌生,尤其是CS架构,客户电脑要运行基于.NET开发的程序,无论是使用C#,还是VB.NET、F#,发布后的程序的运行环境都需要有相应版本的.NET的运行时,否则应用程序将无法正常运行。BS架构下,在服务器上安装指定版本.NET运行时,工作量可以忽略不计。试想,如果是CS架构......
  • 不安装运行时运行.NET程序
    好久没写文章了,有些同学问我公众号是不是废了?其实并没有。其实想写的东西很多很多,主要是最近公司比较忙,以及一些其他个人原因没有时间来更新文章。这几天抽空写了一点点东西,证明公众号还活着。长久以来的认知,对于托管代码.NET/JAVA,都是需要在服务器上安装SDK或者运行时......
  • 更安全的alist手动安装挂载本机存储并使用nginx反代
    alist的手动安装挂载本机存储并使用nginx反代一、下载最新alist软件包wgethttps://github.com/alist-org/alist/releases/download/v3.36.0/alist-linux-amd64.tar.gz二、手动安装alist1.创建alist目录sudomkdir/opt/alist#创建运行alist的用户sudouseradd-r-s/us......
  • ubuntu22.04桌面版安装linux搜狗输入法
    本文参考搜狗输入法官方教程,并针对ubuntu22.04做了一些调整https://pinyin.sogou.com/linux/help.php1.安装fcitx#查看fcitx版本aptinfofcitx|grepVersionWARNING:aptdoesnothaveastableCLIinterface.Usewithcautioninscripts.Version:1:4.2.9.8-5#......