NVIDIA is a manufacture of graphics processing units (GPU), also known as graphics cards.

NVIDIA devices on Linux have two popular device driver options: the opensource drivers from the nouveau project or the proprietary drivers published by NVIDIA. The nouveau drivers are built into the Clear Linux* OS kernel and are loaded automatically at system boot if a compatible card is detected.

These instructions show how to use the proprietary NVIDIA drivers which require a manual installation.

Note

Software installed outside of swupd is not updated with Clear Linux OS updates and must be updated and maintained manually.

Prerequisites

  • A Clear Linux OS system with a desktop installed
  • A NVIDIA device installed

Install DKMS

The Dynamic Kernel Module System (DKMS) allows the NVIDIA kernel modules to be automatically integrated when kernel updates occur in Clear Linux OS.

Install the appropriate DKMS bundle using the instructions below:

Note

The Long Term Support (LTS) kernel variant is more likely to remain compatible between updates with NVIDIA drivers.

The kernel-native-dkms bundle provides the dkms program and Linux kernel headers, which are required for compiling kernel modules.

The kernel-native-dkms bundle also:

  • Adds a systemd update trigger (/usr/lib/systemd/system/dkms-new-kernel.service) to automatically run DKMS to rebuild modules after a kernel upgrade occurs with swupd update.
  • Disables kernel modules signature verification by appending a kernel command-line parameter (module.sig_unenforce) from /usr/share/kernel/cmdline.d/clr-ignore-mod-sig.conf.
  • Adds a notification to the Message of the Day (MOTD) indicating kernel modules signature verification is disabled.

Warning

  1. It is important to always review the output of swupd update to make sure kernel modules rebuilt against the new kernel successfully. This is especially important for systems where a successful boot relies on a kernel module.

Install the kernel-native-dkms or kernel-lts-dkms bundle:

  1. Determine which kernel variant is running on Clear Linux OS. Only the native and lts kernels are enabled to build and load out-of-tree kernel modules with DKMS.

    $ uname -r
    5.XX.YY-ZZZZ.native
    

    Ensure .native or .lts is in the kernel name.

  2. Install the dkms bundle corresponding to the installed kernel. kernel-native-dkms for the native kernel or kernel-lts-dkms for the lts kernel.

    sudo swupd bundle-add kernel-native-dkms
    

    or

    sudo swupd bundle-add kernel-lts-dkms
    
  3. Update the Clear Linux OS bootloader and reboot.

    sudo clr-boot-manager update
    reboot
    

Download and install the NVIDIA Linux Driver

Download the NVIDIA Linux Driver

  1. Identify the model of NVIDIA GPU that is installed.

    sudo lshw -C display
    
  2. Go to the NVIDIA Driver Downloads website . Search for and download the appropriate driver based on the model of NVIDIA GPU you have with Linux 64-bit selected as the Operating System .

  3. Open a terminal and navigate to where the NVIDIA-Linux-x86_64-<VERSION>.run file was saved. In this example, it was saved in the Downloads folder.

    cd ~/Downloads/
    
  4. Make the NVIDIA-Linux-x86_64-<VERSION>.run file executable.

    chmod +x :file:`NVIDIA-Linux-x86_64-<VERSION>.run`
    

Disable the nouveau Driver

The proprietary NVIDIA driver is incompatible with the nouveau driver and needs to be disabled before installation can continue.

  1. Disable the nouveau driver by creating a blacklist file under /etc/modprobe.d and reboot.

    sudo mkdir /etc/modprobe.d
    
    printf "blacklist nouveau \noptions nouveau modeset=0 \n" | sudo tee --append /etc/modprobe.d/disable-nouveau.conf
    
  2. Reboot the system and log back in. It is normal for the graphical environment to not start with no NVIDIA driver loaded.

Install the NVIDIA Linux Driver

The NVIDIA installer will be directed to install files under /opt/nvidia as much as possible to keep its contents isolated from the rest of the Clear Linux OS files under /usr.

  1. A terminal not running on /dev/tty1 is useful to view uninterrupted installation progress. Switch to a secondary virtual terminal by pushing CTRL + ALT + F2 or remotely login over SSH.

  2. Configure the dynamic linker to look for and cache shared libraries under /opt/nvidia/lib and /opt/nvidia/lib32 where the NVIDIA installer will place libraries.

    echo "include /etc/ld.so.conf.d/*.conf" |  sudo tee --append /etc/ld.so.conf
    sudo mkdir /etc/ld.so.conf.d
    printf "/opt/nvidia/lib \n/opt/nvidia/lib32 \n" | sudo tee --append /etc/ld.so.conf.d/nvidia.conf
    
  3. Navigate into the directory where the NVIDIA installer was downloaded.

    cd ~/Downloads/
    
  4. Run the installer with the advanced options below.

    sudo ./NVIDIA-Linux-x86_64-<VERSION>.run \
    --utility-prefix=/opt/nvidia \
    --opengl-prefix=/opt/nvidia \
    --compat32-prefix=/opt/nvidia \
    --compat32-libdir=lib32 \
    --x-prefix=/opt/nvidia \
    --documentation-prefix=/opt/nvidia \
    --no-precompiled-interface \
    --no-nvidia-modprobe \
    --no-distro-scripts \
    --force-libglx-indirect \
    --dkms \
    --silent
    
  5. The graphical interface may automatically start after the NVIDIA driver is loaded. Return to the working terminal and log back in if necessary.

  6. Validate the nvidia kernel modules are loaded.

    lsmod | grep ^nvidia
    
  7. Run a Clear Linux OS system verification to restore files that the NVIDIA installer likely deleted.

    sudo swupd verify --quick --fix --bundles=lib-opengl
    

Note

The NVIDIA software places some files under the /usr subdirectory which are not managed by Clear Linux OS and conflict with the Clear Linux OS stateless design. Although a limited version of swupd verify –fix is ran above, other uses of the swupd verify –fix command should be avoided with the proprietary NVIDIA drivers installed.

Uninstalling the NVIDIA driver

The NVIDIA drivers and associated software can be uninstalled and nouveau driver restored by:

  1. Remove the previously created file /etc/modprobe.d that prevents nouveau from loading.

    sudo rm /etc/modprobe.d/disable-nouveau.conf
    
  2. Run the sudo /opt/nvidia/bin/nvidia-uninstall

  3. Follow the prompts on the screen and reboot the system.

Debugging NVIDIA driver installation

  • The NVIDIA driver places installer and uninstaller logs under /var/log/nvidia-install and /var/log/nvidia-uninstall.
  • NVIDIA-Linux-x86_64-<VERSION>.run --advanced-options shows many parameters to control installation behavior.
  • NVIDIA-Linux-x86_64-<VERSION>.run --extract-only extracts installation files into a directory named NVIDIA-Linux-x86_64-<VERSION>.