PyTorch 1.5.0 通过 pip 安装 CUDA 10.2 始终安装 CUDA 9.2

PyTorch 1.5.0 CUDA 10.2 installation via pip always installs CUDA 9.2

我目前正在安装环境,需要 pytorch 1.5.0 和 CUDA 10.2。 CUDA 驱动程序已设置,一切正常,但通过 pip 下载的 pytorch 已损坏。

之前版本的官方文档说安装应该如下:

CUDA 10.2

pip install torch==1.5.0 torchvision==0.6.0 -f https://download.pytorch.org/whl/torch_stable.html

CUDA 10.1

pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html

CUDA 9.2

pip install torch==1.5.0+cu92 torchvision==0.6.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html

CPU only

pip install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

(来源:https://pytorch.org/get-started/previous-versions/

但是当我尝试为 CUDA 10.2 安装第一个时,它安装了 CUDA 9.2:

$ pip install torch==1.5.0 torchvision==0.6.0 -f https://download.pytorch.org/whl/torch_stable.html
 Looking in links: https://download.pytorch.org/whl/torch_stable.html
 Collecting torch==1.5.0   
 Downloading https://download.pytorch.org/whl/cu92/torch-1.5.0%2Bcu92-cp36-cp36m-linux_x86_64.whl (603.7 MB)
      |████████████████████████████████| 603.7 MB 985 bytes/s 
 Collecting torchvision==0.6.0  
 Downloading  https://download.pytorch.org/whl/cu92/torchvision-0.6.0%2Bcu92-cp36-cp36m-linux_x86_64.whl (6.5 MB)
      |████████████████████████████████| 6.5 MB 600 kB/s 
Requirement already satisfied: future in /home/---/site-packages (from torch==1.5.0) (0.18.2)
Requirement already satisfied: numpy in /home/---/python3.6/site-packages (from torch==1.5.0) (1.19.1) 
Requirement already satisfied: pillow>=4.1.1 in /home/---/site-packages (from torchvision==0.6.0) (7.2.0) Installing collected packages: torch, torchvision 
Successfully installed torch-1.5.0+cu92
 torchvision-0.6.0+cu92

所以,它下载并安装了错误的版本。像其他版本一样向版本显式添加 +cu102 也不起作用,因为它会给出错误:

$ pip install torch==1.5.0+cu102 torchvision==0.6.0+cu102 -f https://download.pytorch.org/whl/torch_stable.html
Looking in links: https://download.pytorch.org/whl/torch_stable.html
ERROR: Could not find a version that satisfies the requirement torch==1.5.0+cu102 (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 0.3.0.post4, 0.3.1, 0.4.0, 0.4.1, 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.2.0+cpu, 1.2.0+cu92, 1.3.0, 1.3.0+cpu, 1.3.0+cu100, 1.3.0+cu92, 1.3.1, 1.3.1+cpu, 1.3.1+cu100, 1.3.1+cu92, 1.4.0, 1.4.0+cpu, 1.4.0+cu100, 1.4.0+cu92, 1.5.0, 1.5.0+cpu, 1.5.0+cu101, 1.5.0+cu92, 1.5.1, 1.5.1+cpu, 1.5.1+cu101, 1.5.1+cu92, 1.6.0, 1.6.0+cpu, 1.6.0+cu101, 1.6.0+cu92)
ERROR: No matching distribution found for torch==1.5.0+cu102

手动下载轮子并通过删除 cu92 部分或将其替换为 cu102 来更改 https://download.pytorch.org/whl/cu92/torch-1.5.0%2Bcu92-cp36-cp36m-linux_x86_64.whl 也不起作用,并且会导致 pytorch 服务器出现错误 403。

遗憾的是,在这种情况下我确实依赖 pip,无法使用 conda install 命令。有人能解决这个问题吗?

您始终可以手动下载并安装 .whl 个文件:

您可以在 https://download.pytorch.org/whl/torch_stable.html 上查看这些链接。向下滚动到 cu102/ 部分。如果需要,您会在那里找到其他版本。