Windows 11(CUDA 12)安装PyTorch 2.0.0+cu117遇版本匹配错误求助
问题描述
我在装有CUDA 12和Python 3.10的Windows 11设备上,尝试安装带CUDA支持的PyTorch。运行nvcc --version得到如下输出:
nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2023 NVIDIA Corporation Built on Tue_Aug_15_22:09:35_Pacific_Daylight_Time_2023 Cuda compilation tools, release 12.2, V12.2.140 Build cuda_12.2.r12.2/compiler.33191640_0
想要安装带CUDA支持的PyTorch 2.0.0版本,执行了以下命令:
python -m pip install torch==2.0.0+cu117
但遇到错误:
ERROR: Could not find a version that satisfies the requirement torch==2.0.0+cu117 (from versions: 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 2.0.0, 2.0.1) ERROR: No matching distribution found for torch==2.0.0+cu117
解决建议
- 使用官方源指定CUDA版本安装:直接用
+cu117的版本标识在Windows环境下无法被pip正确识别,需通过PyTorch官方whl源安装适配cu117的2.0.0版本,执行命令:python -m pip install torch==2.0.0 torchvision==0.15.1 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu117 - 无需降级CUDA:你的系统是CUDA 12.2,PyTorch 2.0.0最高适配cu117,但CUDA具备向下兼容性,cu117版本的PyTorch可在CUDA 12.x环境下正常运行,不用特意降级CUDA。
- 验证CUDA可用性:安装完成后,运行以下代码确认PyTorch是否成功启用CUDA:
输出import torch print(torch.cuda.is_available())True则说明安装成功。
内容的提问来源于stack exchange,提问作者Marco Parola
相关产品推荐
相关产品推荐

