栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

解决python3.7与torch版本不匹配问题

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

解决python3.7与torch版本不匹配问题

#解决python3.7与torch版本不匹配问题

##问题:RuntimeError: The NVIDIA driver on your system is too old (found version 10010). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver.
##解决:
pip install torch1.7.1+cu101 torchvision0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

问题:RuntimeError: No CUDA GPUs are available
解决方法:

// 检测一下cuda是否可用
print(torch.cuda.is_available())
False
//重新在文件头加入下面说明
import torch
torch.cuda.current_device()
torch.cuda._initialized = True

参考博客

解决方法:
1、首先在报错的位置net.cuda前加入cuda检测语句:

print(torch.cuda.is_available())
1
输出为False,证明cuda不可用
2、检查本机中的cuda是否安装成功,且版本号是否与pytorch的版本号对应。检查发现没有问题
3、检查os.environ[“CUDA_VISIBLE_DEVICES”] = "1"语句,将1改为0,再运行无误。原因可能是本机上只有一个cuda,序号应为0。
参考博客

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/971773.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号