NVidia Driver Status Linux Commands & Headless X11

This is a short post listing the ways to check the NVidia driver status at different levels of the Linux system.

Prepared as gist

Hardware Present

lspci | grep -i nvidia

Checks if the NVidia GPU is visible on the PCI bus

Package Installed

dpkg --status nvidia-current
dpkg -l | grep nvidia

The second command checks if the driver is installed as a debian package instead of installed via the executable driver from NVidia.

Module Known
  1. modinfo nvidia
  2. dkms status | grep nvidia
Checks if the driver is known to Linux, and in particular as DKMS, located in /lib/modules/*/updates/dkms/. For nvidia it could be to have the driver in multiple location as in dkms and in a per-version subfolder (e.g. 340).

The modprobe command uses the entries in /etc/modprobe.d and for nvidia could happen to have more than one.

Driver Loaded
  1. cat /proc/driver/nvidia/version
  2. lsmod | grep nvidia
  3. ls /dev/nvidia*
The first command prints the driver version
The last command shows the driver devices (nvidia0 and nvidiactl), useful for permission and for transfer to docker.

Module-Driver correspondence
  1. nvidia-smi
The nvidia-smi command provides detailed information about the driver, CUDA and the hardware. If the driver is loaded and this command fails means that there is a mismatch between the driver and nvidia-smi.

  1. nvidia-xconfig --query-gpu-info
  2. glxinfo | grep OpenGL
Before installing the X11 configuration it is possible to query the GPU. The resulting information can be used with nvidia-xconfig --busid.
The last command, glxinfo, succeeds only with an active X11 session (or set via DISPLAY) and the GLX extension loaded

There are some cases in which 1. works but 2. not, and this can be verified with:
grep NVIDIA /var/log/Xorg.0.log"
CUDA issues (lack of nvidia-uvm)
In case the nvidia-uvm is missing CUDA is not working although the rest of the driver seems fine. For solving this issue it is possible to re-create the /dev/nvidia-uvm device (script from Stack Overflow):

/sbin/modprobe nvidia-uvm

if [ "$?" -eq 0 ]; then
  # Find out the major device number used by the nvidia-uvm driver
  D=`grep nvidia-uvm /proc/devices | awk '{print $1}'`

  mknod -m 666 /dev/nvidia-uvm c $D 0
  exit 1

Headless K20m
Taken from https://pleiades.ucsc.edu/hyades/OpenGL_on_Nvidia_K20

nvidia-xconfig --use-display-device=none
sudo Xorg :1 2> /dev/null &
export DISPLAY=:1

Under K20m with driver 378.13 gives OpenGL 4.3

Note that we need to provide read/write access to the /dev/nvidia to obtain version of OpenGL greater than 2.


Popular Posts