解决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 torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

安装cuda101 torch==1.8.0版本

pip install torch==1.8.0+cu101 torchvision==0.9.0+cu101 torchaudio==0.8.0 -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。
参考博客

解决方案2:

  1. 在这个网站找到与cuda相关的torch版本,并下载:
    https://download.pytorch.org/whl/cu101/torch_stable.html
  2. 下载后使用:pip install 刚刚下载的文件名。进行安装
  3. 验证是否安装成功:
python
import torch 
print(torch.__version__)
#输出版本
print(torch.cuda.is_available())
#输出:true

完成以上步骤安装成功!

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值