如何安装适配的pytorch

这种情况下如何安装cuda适配的pytorch?我的cuda驱动版本是12.0,搭载的11.7的cuda和对应的cudnn以及当前最高版本的pytorch但仍然说不适配

img

你看看这篇超详细安装讲解:https://blog.csdn.net/Bluebro/article/details/127161165

  • 关于该问题,我找了一篇非常好的博客,你可以看看是否有帮助,链接:如何查看pytorch对应cuda的版本
  • 除此之外, 这篇博客: 【PyTorch】安装支持cuda的pytorch-1.10.2中的 2、安装支持cuda的pytorch 1.10.2 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • Pytorch支持cuda的Stable(1.10.2),其pip安装命令如下:

    pip3 install torch==1.10.2+cu113 torchvision==0.11.3+cu113 torchaudio==0.10.2+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
    

    说明:

    -f, --find-links <url>
    
    If a URL or path to an html file, then parse for links to archives such as sdist (.tar.gz) or wheel (.whl) files. If a local path or file:// URL that’s a directory, then look for archives in the directory listing. Links to VCS project URLs are not supported.
    

    即-f 就是从指定url文件中查找包的下载链接,从后面紧跟的url参数获得的文件中,找pip要安装的包文件。

    安装细节:

    jn-ai@test:~/cuda$ pip3 install torch==1.10.2+cu113 torchvision==0.11.3+cu113 torchaudio==0.10.2+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
    
    Looking in links: https://download.pytorch.org/whl/cu113/torch_stable.html
    Collecting torch==1.10.2+cu113
      Downloading https://download.pytorch.org/whl/cu113/torch-1.10.2%2Bcu113-cp38-cp38-linux_x86_64.whl (1821.4 MB)
         |████████████████████████████████| 1821.4 MB 9.5 kB/s
    Collecting torchvision==0.11.3+cu113
      Downloading https://download.pytorch.org/whl/cu113/torchvision-0.11.3%2Bcu113-cp38-cp38-linux_x86_64.whl (24.5 MB)
         |████████████████████████████████| 24.5 MB 450 kB/s
    Collecting torchaudio==0.10.2+cu113
      Downloading https://download.pytorch.org/whl/cu113/torchaudio-0.10.2%2Bcu113-cp38-cp38-linux_x86_64.whl (2.9 MB)
         |████████████████████████████████| 2.9 MB 457 kB/s
    Collecting typing-extensions
      Downloading typing_extensions-4.1.1-py3-none-any.whl (26 kB)
    Requirement already satisfied: pillow!=8.3.0,>=5.3.0 in /usr/lib/python3/dist-packages (from torchvision==0.11.3+cu113) (7.0.0)
    Collecting numpy
      Downloading numpy-1.22.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 MB)
         |████████████████████████████████| 16.8 MB 55 kB/s
    Installing collected packages: typing-extensions, torch, numpy, torchvision, torchaudio
      WARNING: The scripts convert-caffe2-to-onnx, convert-onnx-to-caffe2 and torchrun are installed in '/home/hl-ai/.local/bin' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
      WARNING: The scripts f2py, f2py3 and f2py3.8 are installed in '/home/hl-ai/.local/bin' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
    Successfully installed numpy-1.22.2 torch-1.10.2+cu113 torchaudio-0.10.2+cu113 torchvision-0.11.3+cu113 typing-extensions-4.1.1
    jn-ai@test:~/cuda$