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

>>>
相关推荐
wx7408513268 分钟前
小琳AI课堂:机器学习
人工智能·机器学习
FL162386312916 分钟前
[数据集][目标检测]车油口挡板开关闭合检测数据集VOC+YOLO格式138张2类别
人工智能·yolo·目标检测
YesPMP平台官方18 分钟前
AI+教育|拥抱AI智能科技,让课堂更生动高效
人工智能·科技·ai·数据分析·软件开发·教育
FL162386312943 分钟前
AI健身体能测试之基于paddlehub实现引体向上计数个数统计
人工智能
黑客-雨1 小时前
构建你的AI职业生涯:从基础知识到专业实践的路线图
人工智能·产品经理·ai大模型·ai产品经理·大模型学习·大模型入门·大模型教程
子午1 小时前
动物识别系统Python+卷积神经网络算法+TensorFlow+人工智能+图像识别+计算机毕业设计项目
人工智能·python·cnn
营赢盈英1 小时前
Azure OpenAI and token limit
ai·chatgpt·asp.net·azure·openai api
大耳朵爱学习1 小时前
掌握Transformer之注意力为什么有效
人工智能·深度学习·自然语言处理·大模型·llm·transformer·大语言模型
TAICHIFEI1 小时前
目标检测-数据集
人工智能·目标检测·目标跟踪
qq_15321452641 小时前
【2023工业异常检测文献】SimpleNet
图像处理·人工智能·深度学习·神经网络·机器学习·计算机视觉·视觉检测