当前位置: 首页 > news >正文

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

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

(l2) D:\opt\l2>pythonPython 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:34:57) [MSC v.1936 64 bit (AMD64)] on win32Type "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 torchaudioFound existing installation: torch 2.1.0Uninstalling 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.exec:\users\xxxxxx\.conda\envs\l2\scripts\convert-onnx-to-caffe2.exec:\users\xxxxxx\.conda\envs\l2\scripts\torchrun.exeProceed (Y/n)? ySuccessfully uninstalled torch-2.1.0Found existing installation: torchvision 0.16.0Uninstalling 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)? ySuccessfully uninstalled torchvision-0.16.0Found existing installation: torchaudio 2.1.0Uninstalling 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)? ySuccessfully 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 win32Type "help", "copyright", "credits" or "license" for more information.>>> import torch>>> torch.cuda.is_available()True>>>

http://www.lryc.cn/news/222029.html

相关文章:

  • 零代码编程:用ChatGPT批量将Mp4视频转为Mp3音频
  • 微服务项目,请求从发出到后端处理器的历程
  • pandas教程:String Manipulation 字符串处理和正则表达式re
  • Apache Doris 是什么
  • 【NeurIPS 2020】基于蒙特卡罗树搜索的黑箱优化学习搜索空间划分
  • 面试题:线上MySQL的自增id用尽怎么办?
  • Java集合框架:Collection 与 Map 接口深度解析
  • qt多线程例子,不断输出数字
  • 基于厨师算法的无人机航迹规划-附代码
  • 设计模式的六大原则
  • 原文远知行COO张力加盟逐际动力 自动驾驶进入视觉时代?
  • 【公益案例展】火山引擎公益电子票据服务——连接善意,共创美好
  • postman中文乱码
  • 设计模式简要介绍
  • LeetCode-232. 用栈实现队列(C++)
  • 无人机红外相机的畸变矫正
  • C++编程案例讲解-基于结构体的控制台通讯录管理系统
  • ASP.NETCore6开启文件服务允许通过url访问附件(图片)
  • python爬取Web of science论文信息
  • 本地域名 127.0.0.1 / localhost
  • Python —— 不同类型的数据长度计算方式
  • NowCoder | 环形链表的约瑟夫问题
  • 华为政企数据中心网络交换机产品集
  • 多门店自助点餐+外卖二合一小程序源码系统 带完整搭建教程
  • kafka可视化工具
  • Excel 转 Json 、Node.js实现(应用场景:i18n国际化)
  • Redis7--基础篇2(Redis的十大数据类型及常用命令)
  • 1.HTML中网页介绍
  • 执行sql报错only_full_group_by的解决方法
  • 不学51直接学stm32可以吗?学stm32需要哪些基础?