Install NVIDIA GPU driver on Ubuntu

This article explains how to install NVIDIA GPU drivers on Ubuntu.

Prerequisites

  • The host systems and the installed GPU devices must meet the system requirements for GPU support.

    For more information, see System requirements for GPU support.

  • Each host system must be updated with the latest OS kernel and packages, and must then be restarted before you install the GPU driver.

  • You must be root or have sudo privileges on the hosts.

Install the NVIDIA GPU driver

The following procedure explains how to install the driver on Ubuntu.

We recommend that you always use the Linux distribution package manager to install the NVIDIA GPU drivers.

Step 1: Choose the driver version and create an environment variable

Choose the matching driver major version for the GPU based on the recommendations in System requirements for GPU support, and configure this version as a shell environment variable DRIVER_VERSION to be used in the following installation steps.

Example:
Copy
# Example: Using the LTS 535 driver
export DRIVER_VERSION=535

Step 2: Install the driver

Install the NVIDIA DKMS-based kernel drivers by following the procedure in Manual driver installation (using APT) in the Ubuntu server documentation.

The installation procedure can be summarized in the following steps:

  1. Install prerequisites (kernel headers):

    Copy
    sudo apt update
    sudo apt install linux-headers-$(uname -r)
  2. Install the server variant of the DKMS kernel and user space drivers:

    Copy
    sudo apt install -y nvidia-dkms-${DRIVER_VERSION}-server nvidia-driver-${DRIVER_VERSION}-server

Step 3 (optional): Install additional packages for multi-GPU systems

For systems using multiple NVIDIA GPUs with NVLink GPU interconnect, you must install the NVIDIA Fabric Manager as well as the NVSwitch Configuration and Query library (NSCQ) packages for the configured driver version:

Copy
sudo apt install -y nvidia-fabricmanager-${DRIVER_VERSION} libnvidia-nscq-${DRIVER_VERSION}

For more information, see Installing Fabric Manager and the NSCQ library in the Ubuntu server documentation.

Step 4: Restart the system

After you have installed the driver and the additional packages, a system restart is required.

Install the NVIDIA Container Toolkit

Install the NVIDIA Container Toolkit following the procedure Installing the NVIDIA Container Toolkit in the NVIDIA documentation.

Summary of the installation procedure (see the NVIDIA documentation for details):

  1. Install the prerequisites for the following steps.

  2. Add the NVIDIA Container Toolkit production repository to the OS package manager repositories.

  3. Update the package manager.

  4. Install the nvidia-container-toolkit software package using the package manager.

    Make sure that you pin the software package to a fixed version.

We recommend that you only execute explicit updates to newer container toolkit versions during OS updates, and that you always use pinned package versions to prevent automatic updates.

Updating the driver

To update to the newest release of the same major version of the driver, use normal package updates with apt.