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

>>>
相关推荐
运器1239 分钟前
【一起来学AI大模型】PyTorch DataLoader 实战指南
大数据·人工智能·pytorch·python·深度学习·ai·ai编程
超龄超能程序猿23 分钟前
(5)机器学习小白入门 YOLOv:数据需求与图像不足应对策略
人工智能·python·机器学习·numpy·pandas·scipy
卷福同学24 分钟前
【AI编程】AI+高德MCP不到10分钟搞定上海三日游
人工智能·算法·程序员
帅次32 分钟前
系统分析师-计算机系统-输入输出系统
人工智能·分布式·深度学习·神经网络·架构·系统架构·硬件架构
AndrewHZ1 小时前
【图像处理基石】如何入门大规模三维重建?
人工智能·深度学习·大模型·llm·三维重建·立体视觉·大规模三维重建
5G行业应用1 小时前
【赠书福利,回馈公号读者】《智慧城市与智能网联汽车,融合创新发展之路》
人工智能·汽车·智慧城市
悟空胆好小1 小时前
分音塔科技(BABEL Technology) 的公司背景、股权构成、产品类型及技术能力的全方位解读
网络·人工智能·科技·嵌入式硬件
探讨探讨AGV1 小时前
以科技赋能未来,科聪持续支持青年创新实践 —— 第七届“科聪杯”浙江省大学生智能机器人创意竞赛圆满落幕
人工智能·科技·机器人
cwn_2 小时前
回归(多项式回归)
人工智能·机器学习·数据挖掘·回归
聚客AI2 小时前
🔥 大模型开发进阶:基于LangChain的异步流式响应与性能优化
人工智能·langchain·agent