解决 ERROR: Could not find a version that satisfies the requirement torch==1.10.0+cu102

文章讲述了在Windows10系统上,由于Python3.10与PyTorch的CUDA10.2版本不兼容导致的安装失败问题。解决方案是降级到Python3.8,并使用特定CUDA版本的安装指令进行安装,最终成功安装了PyTorch、Torchvision和Torchaudio并验证了CUDA的可用性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前提

笔者的问题不是网络问题
python版本:3.10
本机CUDA版本:10.2
OS:Windows10

问题

下载torch时报错:

pip install torch==1.10.0+cu102 torchvision==0.11.0+cu102 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.html
Looking in indexes: https://mirrors.cloud.tencent.com/pypi/simple
Looking in links: https://download.pytorch.org/whl/torch_stable.html

ERROR: Could not find a version that satisfies the requirement torch==1.10.0+cu102 (from versions: 1.11.0, 1.11.0+cpu, 1.11.0+cu113, 1.11.0+cu115, 1.12.0, 1.12.0+cpu, 1.12.0+cu113, 1.12.0+cu116, 1.12.1, 1.12.1+cpu, 1.12.1+cu113, 1.12.1+cu116, 1.13.0, 1.13.0+cpu, 1.13.0+cu116, 1.13.0+cu117, 1.13.1, 1.13.1+cpu, 1.13.1+cu116, 1.13.1+cu117, 2.0.0, 2.0.0+cpu, 2.0.0+cu117, 2.0.0+cu118)
ERROR: No matching distribution found for torch==1.10.0+cu102

原因

python3.10目前在pytorch提供的库中根本没有对应的windows10环境的torch库

https://download.pytorch.org/whl/torch
注:cu代表CUDA版本,cp代表python版本

在这里插入图片描述

解决

安装python3.8,注意添加环境变量
在这里插入图片描述

然后以管理员身份打开cmd,执行安装指令


C:\Windows\system32>pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu102
Looking in indexes: https://download.pytorch.org/whl/cu102
Collecting torch
  Using cached https://download.pytorch.org/whl/cu102/torch-1.10.2%2Bcu102-cp38-cp38-win_amd64.whl (1486.0 MB)
Collecting torchvision
  Using cached https://download.pytorch.org/whl/cu102/torchvision-0.11.3%2Bcu102-cp38-cp38-win_amd64.whl (2.6 MB)
Collecting torchaudio
  Using cached https://download.pytorch.org/whl/cu102/torchaudio-0.10.2%2Bcu102-cp38-cp38-win_amd64.whl (336 kB)
Collecting typing-extensions
  Using cached https://download.pytorch.org/whl/typing_extensions-4.4.0-py3-none-any.whl (26 kB)
Collecting pillow!=8.3.0,>=5.3.0
  Using cached https://download.pytorch.org/whl/Pillow-9.3.0-cp38-cp38-win_amd64.whl (2.5 MB)
Collecting numpy
  Using cached https://download.pytorch.org/whl/numpy-1.24.1-cp38-cp38-win_amd64.whl (14.9 MB)
Installing collected packages: typing-extensions, torch, pillow, numpy, torchvision, torchaudio
Successfully installed numpy-1.24.1 pillow-9.3.0 torch-1.10.2+cu102 torchaudio-0.10.2+cu102 torchvision-0.11.3+cu102 typing-extensions-4.4.0

C:\Windows\system32>python
Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
True
>>> torch.__version__
'1.10.2+cu102'

指令来源:https://pytorch.org/get-started/locally/
我这里直接将后缀改为自己的CUDA版本cu102就可以下载
在这里插入图片描述
当然也可以下载其他版本的torch:
https://pytorch.org/get-started/previous-versions
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

那个小白猿

讨杯可乐

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值