问题
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):
解决
- 查看torch版本
import torch
print(torch.__version__) # '1.7.0'
print(torch.version.cuda) # 10.2
- 查看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
- 卸载pytorch
pip uninstall pytorch
pip uninstall pytorchvision
- 安装新版本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
- 检测
import torch
print(torch.__version__) # '1.7.0'
print(torch.version.cuda) # 10.1
完成。