> 文章列表 > wsl安装torch_geometric

wsl安装torch_geometric

wsl安装torch_geometric

  1. 在官网选择需要的版本

  2. 选择安装途径,选择runfile

wsl安装torch_geometric

  1. 执行第一行,会下载一个文件到目录下

wsl安装torch_geometric

  1. 需要降低C++的版本,否则

    执行sudo sh cuda_11.1.0_455.23.05_linux.run,会出现

    wsl安装torch_geometric

    查看对应的文件,会有

    wsl安装torch_geometric

    可以加上override参数之后,继续安装

wsl安装torch_geometric

  1. 降低gcc版本,但是会出现错误

    E: Package ‘g+±7’ has no installation candidate

    wsl安装torch_geometric

  2. 解决E: Package ‘g+±7’ has no installation candidate错误,需要更换ubuntun 20.04的镜像

    # 修改 apt-get 源的配置文件
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份
    sudo vim /etc/apt/sources.list #修改deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse# deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    # deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse#最后执行
    sudo apt-get update
    

    如果删除了原本的镜像源内容,使用nvcc -V命令,发现没有了,安装的话也会失败

    The following packages have unmet dependencies:  nvidia-cuda-toolkit :
    Depends: nvidia-cuda-dev (= 10.1.243-3) but it is not going to be
    installed E: Unable to correct problems, you have held broken
    packages.
    Running `sudo apt install nvidia-cuda-dev` yields:The following packages have unmet dependencies:  nvidia-cuda-dev :
    Depends: libcublas10 (= 10.1.243-3) but 10.2.2.214-1 is to be
    installedRecommends: libvdpau-dev but it is not going to be installedRecommends: libnvcuvid1 but it is not installable E: Unable to correct problems, you have held broken packages.
    

    原因更改了 /etc/apt/sources.list can’t install nvidia-driver-toolkit on Ubuntu 20.04 LTS - needs uninstallable package - Ask Ubuntu

    方法:在/etc/apt/sources.list中添加

    deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiversedeb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiversedeb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
    

    镜像源更改之后,执行

    sudo apt-cache policy
    sudo apt-get --purge remove "*cublas*" "cuda*" "*nvidia*"
    sudo apt-get clean
    sudo apt-get autoremove
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install nvidia-cuda-toolkit
    

    再次执行安装nvcc的命令

  3. 降低g++版本之后,可以正常执行 sudo sh cuda_11.1.0_455.23.05_linux.run, 前面有X的是选中要安装的,[ ]是不安装的

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-KgFx3ljk-1681261652591)(E:\\Linux\\WSL\\wsl安装torch_geometric.assets\\image-20230411171049593.png)]

  4. 安装完成后显示

    wsl安装torch_geometric

  5. 正常安装cuda 11.1了,虽然nvidia-smi显示和nvcc -V显示的版本不同,以nvcc -V为主

    wsl安装torch_geometric

  6. /usr/local目录下有了 cuda目录

    wsl安装torch_geometric

  7. 更新可执行文件路径,在 vim ~/.bashrc中加入,如果不在 ~/.bashrc中加入的话,下次启动还是找不到cuda

    export PATH=/usr/local/cuda-11.1/bin${PATH:+:${PATH}}
    
  8. 更新动态链接库路径,在 vim ~/.bashrc中加入

    export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    
  9. 安装1.8.1版本的torch https://pytorch.org/get-started/previous-versions/

    # CUDA 11.1
    pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
    
  10. 然后安装torch-geometric, 根据torch和cuda版本选择,

    wsl安装torch_geometric

  11. 安装顺序为 torch-scatter2.0.8,torch-sparse0.6.12,torch-cluster1.5.9,torch-spline-conv1.2.1,torch-geometric==1.7.0,我的python版本为3.6, wsl(linux)

抖团网