cuda与pytorch版本不匹配的问题及解决

问题

cuda与pytorch版本不匹配的问题:

### 输入torch.ones((2,3)).cuda()时,报错。
RuntimeError: The NVIDIA driver on your system is too old (found version 10010).

### 运行代码时,报错。 
RuntimeError: CUDA error: CUDA driver version is insufficient for CUDA runtime version
Exception raised from getDevice at /pytorch/c10/cuda/impl/CUDAGuardImpl.h:37 (most recent call first):

解决

  1. 查看torch版本
import torch
print(torch.__version__)  # '1.7.0'
print(torch.version.cuda)  # 10.2
  1. 查看cuda版本
$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:17_PST_2019
Cuda compilation tools, release 10.1, V10.1.105

$ cat /usr/local/cuda/version.txt
CUDA Version 10.1.105
  1. 卸载pytorch
pip uninstall pytorch
pip uninstall pytorchvision
  1. 安装新版本torch1.7+cu10.1
pip install torch==1.7.0+cu101 torchvision==0.8.1+cu101 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
  1. 检测
import torch
print(torch.__version__)  # '1.7.0'
print(torch.version.cuda)  # 10.1

完成。

  • 8
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 9
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值