GPU devices have wrong SELinux context after reboot in CentOS

GPU devices show the wrong SELinux context after the server restarts and cannot be used without restoring the context with restorecon.

ls -Z /dev/nvi*
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia0
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia1
crw-rw-rw-. root root system_u:object_r:device_t:s0 /dev/nvidia2
crw-rw-rw-. root root system_u:object_r:device_t:s0 /dev/nvidia3
crw-rw-rw-. root root system_u:object_r:device_t:s0 /dev/nvidia4
crw-rw-rw-. root root system_u:object_r:device_t:s0 /dev/nvidia5
crw-rw-rw-. root root system_u:object_r:device_t:s0 /dev/nvidia6
crw-rw-rw-. root root system_u:object_r:device_t:s0 /dev/nvidia7
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidiactl
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia-modeset
crw-rw-rw-. root root system_u:object_r:device_t:s0 /dev/nvidia-uvm
crw-rw-rw-. root root system_u:object_r:device_t:s0 /dev/nvidia-uvm-tools

The right context is set after running restorecon.

$ ls -Z /dev/nvi*
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia0
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia1
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia2
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia3
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia4
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia5
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia6
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia7
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidiactl
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia-modeset
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia-uvm
crw-rw-rw-. root root system_u:object_r:xserver_misc_device_t:s0 /dev/nvidia-uvm-tools

  • To resolve this issue, you should check for missing files, as shown below.

/lib/udev/rules.d/60-nvidia-drm.rules
/lib/udev/rules.d/60-nvidia-uvm.rules

These files are present in NVIDIA CUDA drivers.

Leave a Reply

Your email address will not be published. Required fields are marked *