Win10系统下torch.cuda.is_available()返回为False的问题解决

Q: Win10系统下torch.cuda.is_available()返回为False

(l2) D:\opt\l2>python

Python 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:34:57) [MSC v.1936 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> import torch

>>> torch.cuda.is_available()

False

A: 安装指定的torchGPU版本

经查网上资料,说默认用官网命令安装的最新版torch是不加载cuda加速的,而且版本不匹配,需要手动指定版本安装

第一步,卸载已安装的torch2.10版本

pip3 uninstall torch torchvision torchaudio

Found existing installation: torch 2.1.0

Uninstalling torch-2.1.0:

  Would remove:

    c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\functorch\*

    c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torch-2.1.0.dist-info\*

    c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torch\*

    c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torchgen\*

    c:\users\xxxxxx\.conda\envs\l2\scripts\convert-caffe2-to-onnx.exe

    c:\users\xxxxxx\.conda\envs\l2\scripts\convert-onnx-to-caffe2.exe

    c:\users\xxxxxx\.conda\envs\l2\scripts\torchrun.exe

Proceed (Y/n)? y

  Successfully uninstalled torch-2.1.0

Found existing installation: torchvision 0.16.0

Uninstalling torchvision-0.16.0:

  Would remove:

    c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torchvision-0.16.0.dist-info\*

    c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torchvision\*

Proceed (Y/n)? y

  Successfully uninstalled torchvision-0.16.0

Found existing installation: torchaudio 2.1.0

Uninstalling torchaudio-2.1.0:

  Would remove:

    c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torchaudio-2.1.0.dist-info\*

    c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torchaudio\*

Proceed (Y/n)? y

  Successfully uninstalled torchaudio-2.1.0

第二步,安装指定版本的2.0.1的GPU版本

pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1+cu118 -f https://download.pytorch.org/whl/torch_stable.html

也可以离线下载GPU版本,2.0.0,2.0.1, 2.1.0:

https://download.pytorch.org/whl/cu118/torch-2.0.0%2Bcu118-cp310-cp310-win_amd64.whl

https://download.pytorch.org/whl/cu118/torch-2.0.1%2Bcu118-cp310-cp310-win_amd64.whl

https://download.pytorch.org/whl/cu118/torch-2.1.0%2Bcu118-cp310-cp310-win_amd64.whl

(l2) D:\opt\l2>python
Python 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:34:57) [MSC v.1936 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> import torch

>>> torch.cuda.is_available()

True

>>>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

码农丁丁

你的认可是我创作最大的动力

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

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

打赏作者

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

抵扣说明:

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

余额充值