解决 torch.cuda.is_available() 为False

C:\Users\zengke>python
Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
False
>>>

1、下载 cuda

CUDA Toolkit 12.1 Update 1 Downloads | NVIDIA Developer

 安装完查看本机显卡对于的CUDA版本 这里是12.1.112

下载pytorch

Start Locally | PyTorch

选择pythorch对于的版本,可以选择比版本低的

 安装pytorch 命令

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117

过程日志:

C:\Users\zengke>pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
Looking in indexes: https://download.pytorch.org/whl/cu117
Collecting torch
  Downloading https://download.pytorch.org/whl/cu117/torch-2.0.1%2Bcu117-cp310-cp310-win_amd64.whl (2343.6 MB)
     ---------------------------------------- 2.3/2.3 GB 247.4 kB/s eta 0:00:00
Requirement already satisfied: torchvision in d:\install\python\python310\lib\site-packages (0.15.1)
Requirement already satisfied: torchaudio in d:\install\python\python310\lib\site-packages (2.0.1+cu117)
Requirement already satisfied: filelock in d:\install\python\python310\lib\site-packages (from torch) (3.12.0)
Requirement already satisfied: typing-extensions in d:\install\python\python310\lib\site-packages (from torch) (4.5.0)
Requirement already satisfied: sympy in d:\install\python\python310\lib\site-packages (from torch) (1.11.1)
Requirement already satisfied: networkx in d:\install\python\python310\lib\site-packages (from torch) (3.1)
Requirement already satisfied: jinja2 in d:\install\python\python310\lib\site-packages (from torch) (3.1.2)
Requirement already satisfied: numpy in d:\install\python\python310\lib\site-packages (from torchvision) (1.24.3)
Requirement already satisfied: requests in d:\install\python\python310\lib\site-packages (from torchvision) (2.28.2)
  Downloading https://download.pytorch.org/whl/cu117/torch-2.0.0%2Bcu117-cp310-cp310-win_amd64.whl (2343.6 MB)
     ---------------------------------------- 2.3/2.3 GB 254.3 kB/s eta 0:00:00
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in d:\install\python\python310\lib\site-packages (from torchvision) (9.5.0)
Requirement already satisfied: MarkupSafe>=2.0 in d:\install\python\python310\lib\site-packages (from jinja2->torch) (2.1.2)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\install\python\python310\lib\site-packages (from requests->torchvision) (3.1.0)
Requirement already satisfied: idna<4,>=2.5 in d:\install\python\python310\lib\site-packages (from requests->torchvision) (3.4)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in d:\install\python\python310\lib\site-packages (from requests->torchvision) (1.26.14)
Requirement already satisfied: certifi>=2017.4.17 in d:\install\python\python310\lib\site-packages (from requests->torchvision) (2022.12.7)
Requirement already satisfied: mpmath>=0.19 in d:\install\python\python310\lib\site-packages (from sympy->torch) (1.3.0)
Installing collected packages: torch
Successfully installed torch-2.0.0+cu117
C:\Users\zengke>python
Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.__version__)
2.0.0+cu117
>>> torch.cuda.is_available()
True
>>>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值