当前位置:   article > 正文

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

windows torch.cuda.is_available(): false

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

  1. (l2) D:\opt\l2>python
  2. Python 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:34:57) [MSC v.1936 64 bit (AMD64)] on win32
  3. Type "help", "copyright", "credits" or "license" for more information.
  4. >>> import torch
  5. >>> torch.cuda.is_available()
  6. False

A: 安装指定的torchGPU版本

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

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

  1. pip3 uninstall torch torchvision torchaudio
  2. Found existing installation: torch 2.1.0
  3. Uninstalling torch-2.1.0:
  4.   Would remove:
  5.     c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\functorch\*
  6.     c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torch-2.1.0.dist-info\*
  7.     c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torch\*
  8.     c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torchgen\*
  9.     c:\users\xxxxxx\.conda\envs\l2\scripts\convert-caffe2-to-onnx.exe
  10.     c:\users\xxxxxx\.conda\envs\l2\scripts\convert-onnx-to-caffe2.exe
  11.     c:\users\xxxxxx\.conda\envs\l2\scripts\torchrun.exe
  12. Proceed (Y/n)? y
  13.   Successfully uninstalled torch-2.1.0
  14. Found existing installation: torchvision 0.16.0
  15. Uninstalling torchvision-0.16.0:
  16.   Would remove:
  17.     c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torchvision-0.16.0.dist-info\*
  18.     c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torchvision\*
  19. Proceed (Y/n)? y
  20.   Successfully uninstalled torchvision-0.16.0
  21. Found existing installation: torchaudio 2.1.0
  22. Uninstalling torchaudio-2.1.0:
  23.   Would remove:
  24.     c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torchaudio-2.1.0.dist-info\*
  25.     c:\users\xxxxxx\.conda\envs\l2\lib\site-packages\torchaudio\*
  26. Proceed (Y/n)? y
  27.   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

  1. (l2) D:\opt\l2>python
  2. Python 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:34:57) [MSC v.1936 64 bit (AMD64)] on win32
  3. Type "help", "copyright", "credits" or "license" for more information.
  4. >>> import torch
  5. >>> torch.cuda.is_available()
  6. True
  7. >>>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/357436
推荐阅读
相关标签
  

闽ICP备14008679号