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

>>>
相关推荐
CoovallyAIHub5 分钟前
突破360°跟踪极限!OmniTrack++:全景MOT新范式,HOTA指标狂飙43%
深度学习·算法·计算机视觉
ytttr87323 分钟前
MATLAB实现经验模态分解(EMD)与希尔伯特变换获取能量谱
人工智能·python·matlab
AI浩25 分钟前
MHAF-YOLO:用于精确目标检测的多分支异构辅助融合YOLO
人工智能·yolo·目标检测
YangYang9YangYan28 分钟前
高职大数据技术专业学习与发展指南
大数据·人工智能·学习·数据分析
lybugproducer30 分钟前
深度学习专题:模型训练的数据并行(二)
人工智能·深度学习·神经网络
学無芷境32 分钟前
Large-Scale 3D Medical Image Pre-training with Geometric Context Priors
人工智能·3d
大模型服务器厂商34 分钟前
适配的 GPU 服务器能让 AI 模型充分发挥算力优势
人工智能
AscendKing40 分钟前
LandPPT - AI驱动的PPT生成平台
人工智能·好好学电脑·hhxdn.com
FreeCode42 分钟前
LangChain1.0智能体开发:流输出组件
人工智能·langchain·agent
故作春风1 小时前
手把手实现一个前端 AI 编程助手:从 MCP 思想到 VS Code 插件实战
前端·人工智能