目录
1.报错:NVIDIA内核驱动版本和系统驱动不一致(内核版本自动更新了,导致新版本内核和原来显卡驱动不匹配)
2.解决:使用两条命令即可,不同重新安装显卡驱动。
1.报错:
can't initialize NVML
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver.
Make sure that the latest NVIDIA driver is installed and running.
1)用台式机GPU跑代码,突然发现报错:can't initialize NVML。在网上搜索一番,显示出现该问题的原因是:NVIDIA内核驱动版本和系统驱动不一致(内核版本自动更新了,导致新版本内核和原来显卡驱动不匹配)。给出的解决方法基本都是:重新安装驱动。。。
2)在命令行使用nvidia-smi看显卡情况,确实也无法显示,报错:NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
2.解决:
1)查看已安装驱动的版本信息:
ls /usr/src | grep nvidia
发现显卡驱动版本为:nvidia-525.105.17。(显卡驱动是存在的,只是内核驱动版本自动更新了,导致和安装的显卡驱动版本不一致,所以报错。。。)
2)查看已安装内核:
dpkg --get-selections |grep linux-image
查看正在使用的内核:
uname -a
显示为6.2.0-32-generic。因为之前安装nvidia驱动时记下了当时的内核版本为5.19.0-41-generic。所以可以确定确实是因为内核版本更新导致不匹配的问题。
3)依次输入以下两条命令即可:
sudo apt-get install dkms
sudo dkms install -m nvidia -v 525.105.17
#这里的525.105.17是自己的显卡驱动版本
4)再次输入nvidia-smi,可以看到显卡显示成功啦!!!问题解决!!!