Ubuntu:解决显卡驱动问题NVIDIA-SMI has failed because it couldn‘t communicate with the NVIDIA driver.

目录

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

扫描二维码关注公众号,回复: 17181772 查看本文章

查看正在使用的内核:

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,可以看到显卡显示成功啦!!!问题解决!!! 

参考博客:NVIDIA驱动失效简单解决方案:NVIDIA-SMI has failed because it couldn‘t communicate with the NVIDIA driver._nvidia-smi has failed because it couldn't communic-CSDN博客 

解决NVIDIA-SMI has failed because it couldn‘t communicate with the NVIDIA driver_nvidia-smi has failed because it couldn't communic_可即的博客-CSDN博客

猜你喜欢

转载自blog.csdn.net/weixin_39450145/article/details/133643342