成功解决The NVIDIA driver on your system is too old (found version 9000). 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.
文章目录
今天在服务器(Ubuntu 16.04)下载了一个论文的github代码,发现使用了conda虚拟环境。运行时发现报错:
这个时候在虚拟环境里是无法使用CUDA的,实际上使用cuda就会报上述错误。
查看版本对应关系
查找该conda环境的配置要求,发现pytorch版本要求大于等于1.4.0,于是查看base和conda虚拟环境的版本是否出了问题。
查看pytorch版本
import torch
torch.__version__
查看CUDA版本
1.base环境的cuda版本:
cat /usr/local/cuda/version.txt
2.虚拟环境的cuda版本:一般是在
/home/usrname/anaconda3/pkgs/
下有一个cuda开头的文件。
确认pytorch版本和cuda版本是否对应
https://pytorch.org/get-started/previous-versions/
如果你之前用都没问题,说明在base环境二者是匹配的,因为我的conda虚拟环境整体是从git上下载的,所以在conda环境一般也不会有问题。但如果你的虚拟环境里的cuda和pytorch是自己安装的,就应该注意这个问题。
查看NVIDIA显卡驱动版本是否兼容CUDA版本
cat /proc/driver/nvidia/version
NVIDIA官方的CUDA和驱动的版本对应关系
https://blog.csdn.net/weixin_43522055/article/details/99595641

我的驱动版本是384.130,而CUDA分别是8.0.61版本、10.0.13版本。这说明需要升级显卡驱动到410以上版本,才能满足CUDA10的要求。 而高级版本的驱动可以兼容低版本的CUDA,所以只更新显卡驱动就可以了。
更新显卡驱动
主要参考 https://blog.csdn.net/u011119817/article/details/100520669,我决定使用430的显卡驱动版本。
获得的显卡驱动版本
apt search nvidia-430
删除所有用户的目前所有进程
sudo killall -u usrname
移除系统上先前安装的显卡驱动
sudo apt purge nvidia*
如果这里报错,参考
ubuntu遇到了 dpkg was interrupted, you must manually run 'dpkg…的问题
E: Sub-process /usr/bin/dpkg returned an error code (1)解决办法
这个时候
nvidia-smi
会报错说明已经卸载了。
安装显卡驱动
sudo apt install nvidia-430 nvidia-settings nvidia-prime
重启电脑
sudo reboot
重新登陆,再次
nvidia-smi
会正常显示
再次查看NVIDIA显卡驱动版本
cat /proc/driver/nvidia/version
会显示430.64
虚拟环境中
import torch
torch.cuda.is_available()
显示True则安装成功。