问题概述
由于服务器(操作系统为RedHat 9)宕机,重启后,系统内核自动更新了,然后输入 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.
上述其实是由于系统更新后,Nvidia驱动中的系统内核头文件无法使用导致的。
重新启动计算机后,NVIDIA SMI会显示NVIDIA驱动程序丢失,这是由于Linux内核升级,以前的NVIDIA驱动程序与连接不匹配。
解决方法
【这里主要针对系统中仍然还存在 nvidia 驱动来操作】
1 检查Nvidia是否在操作系统
命令行输入 nvcc -V
出现下面的情况 说明系统中的 Nvidia-smi 驱动未损坏 或者卸载。

2 安装kms
DKMS(Dynamic Kernel Module System)可以在内核变化后自动编译模块,并适应新的内核。它允许离散内核模块更新,而无需修改整个内核。使用 dkms 重新安装内核的相应驱动程序:
Red Hat系统中安装DKMS的命令:
sudo yum install epel-release
sudo yum install dkms




3 检查Nvidia驱动版本
ls /usr/src | grep nvidia

4 使用kms更新驱动
dkms install -m nvidia -v 535.171.04


5 重新输入 nvidia-smi,验证成功

【如果上述过程不行,可尝试重新安装驱动。】