sudo 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.
时间: 2025-05-24 07:13:36 浏览: 94
### 解决方案
当遇到 `NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver` 错误时,通常是因为系统中的 NVIDIA 驱动未正确安装或配置不当所致。以下是可能的原因以及解决方案:
#### 1. **确认 NVIDIA 驱动已正确安装**
系统中可能存在旧版驱动或者驱动未完全卸载的情况。可以通过以下方法验证并修复:
- 使用命令 `lsmod | grep nvidia` 检查模块是否加载成功[^1]。
- 如果无任何输出,则说明 NVIDIA 驱动未被加载到内核中。
若驱动未加载,可以尝试重启计算机以完成驱动的初始化过程。如果仍然失败,需重新安装驱动程序。
#### 2. **检查硬件兼容性和 BIOS 设置**
确认 GPU 是否支持当前操作系统版本,并确保 BIOS 中启用了对独立显卡的支持功能(如 iGPU 和 dGPU 同时存在的情况下)。某些情况下禁用集成显卡可能会解决问题[^3]。
#### 3. **更新或降级 NVIDIA 驱动**
当前使用的驱动版本可能导致冲突,尤其是手动调整过驱动版本之后更容易出现问题。建议按照官方文档指导下载适合系统的稳定版本驱动器包进行替换操作[^4]:
```bash
sudo apt-get purge nvidia*
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
ubuntu-driver devices # 查看推荐驱动型号
sudo apt install nvidia-driver-[version_number]
```
替换 `[version_number]` 为你所需的特定版本号,例如 `sudo apt install nvidia-driver-470`。
#### 4. **重建 DKMS 模块**
动态内核模块支持 (DKMS) 可能未能同步最新更改至新编译好的核心映像文件里去;此时可执行如下脚本强制重做一遍整个流程:
```bash
cd /var/lib/dkms/nvidia/[driver_version]/build/
make clean && make
modprobe nvidia
```
此外还可以通过 GUI 工具 Additional Drivers 来管理附加组件的选择工作流简化步骤[^5]。
---
### 示例代码片段
为了便于理解如何排查问题,提供一段简单的调试脚本供参考:
```python
import os
def check_nvidia_driver():
try:
result = os.popen('nvidia-smi').read()
if 'failed' in result.lower() or 'communication error' in result.lower():
return False, "Driver communication issue detected."
else:
return True, "NVIDIA SMI is functioning properly."
except Exception as e:
return None, str(e)
status, message = check_nvidia_driver()
print(f"NVIDIA Driver Status: {message}")
```
此 Python 脚本可用于自动化检测环境状态以便快速定位异常情况。
---
阅读全文
相关推荐



















