nvidia-smi输出中gpu卡丢失或报错
1.问题描述
执行nvidia-smi命令时发现GPU卡丢失或报错:
Unable to determine the device handle for GPU 000:05:00.0: GPU is lost .Reboot the system to recover this ....
2.处理方法
开启GPU驱动内存常驻模式,开启方法:
# nvidia-smi -pm 1
该命令会在节点系统重启后失效,需要将命令添加到开机自动启动脚本中,rhel/centos系统设置参考如下:
# nvidia-smi -pm 1
# vim /etc/rc.local
nvidia-smi -pm 1 ##将改行添加到/etc/rc.local文件中保存退出,
注意将/etc/rc.local设置为可执行权限
# chmod +x /etc/rc.local
3.问题根因
关于 GPU 内存常驻模式,官方的解释为:
A flag that indicates whether persistence mode is enabled for the GPU. Value is either "Enabled" or "Disabled". When persistence mode is enabled the NVIDIA driver remains loaded even when no active clients, such as X11 or nvidia-smi, exist. This minimizes the driver load latency associated with running dependent apps, such as CUDA programs. For all CUDA-capable products. Linux only.
也就是说, linux 系统下,在 persistence 模式是 enabled 状态时, GPU 驱动一直处于加载状态, 减少运行程序时驱动加载的延迟。 不开启该模式时,在程序每次调用完 GPU 后, GPU driver 都会被卸载,下次调用时再重新加载, driver 频繁卸载加载, GPU 频繁被初始化,会导致 GPU 死机, CPU 访问 PCIe config registers时间过长导致 softlock, 最终造成 GPU 掉卡、温度监测异常等情况。
4.建议与总结
后续进行项目实施时开启gup驱动内存常驻模式并加入开机自启动。