How to Install the NVIDIA GPU Drivers on a Headless Ubuntu Server 22.04 LTS

NVIDIA GPUs are required even on screenless Ubuntu servers (no graphical user interface installed) to encode/decode the media files, run the artificial intelligence codes, run the CUDA programs, and more.

In this article, we will show you how to install the official NVIDIA GPU drivers on a Ubuntu Server 22.04 LTS headless computer.

Theme content:

  1. Connect to the Ubuntu Server 22.04 LTS via SSH
  2. Verify that the NVIDIA GPU is installed
  3. Updating the APT package repository cache
  4. Available NVIDIA drivers for Headless Ubuntu Server 22.04 LTS
  5. Installing the latest version of NVIDIA drivers on Ubuntu Server 22.04 LTS
  6. Verify that the NVIDIA drivers are installed correctly
  7. Diploma
  8. references

Connecting to the Ubuntu Server 22.04 LTS machine via SSH

Connecting to your Ubuntu Server 22.04 LTS machine via SSH is optional if you have access to the server hardware (on which you installed Ubuntu Server 22.04 LTS). You can simply connect a mouse, keyboard and monitor to the server and install the NVIDIA drivers on them.

If you do not have access to the Ubuntu Server 22.04 LTS server hardware, you will need to establish an SSH connection to install the NVIDIA drivers.

To SSH into your Ubuntu Server 22.04 LTS machine, you can run the following command from a terminal app of your desktop/laptop from which you want to access the Ubuntu Server 22.04 LTS machine:

$ ssh @

Make sure you and with the login username and domain name or IP address of your Ubuntu Server 22.04 LTS machine.

If you’re using Windows 10 or Windows 11 and need help connecting to your Ubuntu Server 22.04 LTS machine via SSH, keep reading the article How to SSH into the Linux servers from Windows 10/11.

Verify that the NVIDIA GPU is installed

Run the following command to verify if you have an NVIDIA GPU installed on your Ubuntu server machine:

$ lspci | egrep -I ‘vga|display|3d’

As you can see, we installed an NVIDIA GeForce 1050 Ti GPU on our Ubuntu server machine.

You can also see from the output of the following commands that the open source Nouveau drivers are being used instead of the official NVIDIA GPU drivers. In the next sections, we will show you how to install the official NVIDIA GPU drivers on your Ubuntu server.

$lsmod | grep nvidia

$lsmod | grep nouveau

Updating the APT package repository cache

Before you can install the official NVIDIA drivers on the Ubuntu servers, you should update the APT package repository cache with the following command:

$ sudo appropriate update

The APT package repository cache should be updated.

Available NVIDIA drivers for Headless Ubuntu Server 22.04 LTS

You can install either of the two official NVIDIA driver packages on a Headless Ubuntu Server 22.04 LTS:

  1. nvidia-driver-[version]-Server – Install this NVIDIA driver package if you want to install official NVIDIA drivers on your Ubuntu Server 22.04 LTS Headless computer, including all recommended packages and NVIDIA tools.
  2. nvidia-headless-[version]-Server – Install this NVIDIA driver package if you want to install only required official NVIDIA driver components and omit all recommended packages and NVIDIA tools to keep your Ubuntu server as light as possible.

If you choose to install the nvidia headless[version]-server package to install the official NVIDIA drivers on your Ubuntu server, you may also want to install one or both of the NVIDIA packages:

  1. nvidia-utils-[version]-Server – Install this package if you need to run the nvidia-smi command to monitor GPU usage on your Ubuntu server.
  2. libnvidia-encode-[version]-Server – Install this package if you want to encode and decode the media on your Ubuntu server using NVENC or NVDEC capabilities of your NVIDIA GPU.

Here is the version number of the NVIDIA driver that you will install on your Ubuntu Server 22.04 LTS machine. At the time of writing, you can install the NVIDIA driver version 418, 515, or 525 from the Ubuntu official package repository. If you are reading this article, you may find the updated versions of the NVIDIA driver packages in the Ubuntu official package repository. So it’s always a good idea to check if an updated driver version is available before installing. Also, make sure you install the same versions of all NVIDIA driver packages. The version numbers of the NVIDIA driver packs and the NVIDIA tool packs should match.

You can see the available versions of the nvidia-driver-package-server can be found with the following command:

$ sudo apt search ‘^nvidia-driver-[1-9]*-server$’

You can check the available versions of the nvidia-headless-package-server can be found with the following command:

$ sudo apt search ‘^nvidia-headless-[1-9]*-server$’

You can find the available versions of the package nvidia-utils--server with the following command:

$ sudo apt search ‘nvidia-utils-[1-9]*-Server’

You can check the available versions of the libnvidia-encode--server can be found with the following command:

$ sudo apt search ‘libnvidia-encode-[1-9]*-Server’

Installing the latest version of NVIDIA drivers on Ubuntu Server 22.04 LTS

Run the following command to install the official NVIDIA drivers including all recommended NVIDIA tool packages on your headless Ubuntu Server 22.04 LTS machine:

$ sudo apt install nvidia-driver-525-server

Run the following command to install the minimal version of the official NVIDIA drivers and NVIDIA driver utilities on your headless Ubuntu Server 22.04 LTS machine:

$ sudo apt install nvidia-headless-525-server nvidia-utils-525-server

Run the following command to install the minimal version of the official NVIDIA drivers, the NVIDIA driver utilities, and the NVIDIA NVENC encoder and NVDEC decoder libraries on your headless Ubuntu Server 22.04 LTS machine:

$ sudo apt install nvidia-headless-525-server nvidia-utils-525-server libnvidia-encode-525-server

To confirm the installation, press Y and then press .

The NVIDIA driver packages and the required dependency packages will be downloaded. It takes a while to finish.

The NVIDIA driver packages and required dependency packages will be installed. It takes a while to finish.

Once you see the prompts, press to choose from and press .

The NVIDIA drivers should be installed on your Headless Ubuntu Server 22.04 LTS machine.

For the changes to take effect, restart your Ubuntu server with the following command:

$ sudo reboot

Verify that the NVIDIA drivers are installed correctly

Once your Ubuntu server is up and running, you can use the following commands to verify that the NVIDIA kernel modules are being used instead of the open-source Nouveau kernel modules. So the official NVIDIA GPU drivers work fine:

$lsmod | grep nouveau

$lsmod | grep nvidia

You can also find your NVIDIA GPU usage information with the nvidia-smi command. The output of this command also verifies that your NVIDIA GPU drivers are installed correctly.

$nvidia smi

Diploma

We showed you how to check if you have an NVIDIA GPU installed on your Ubuntu Server 22.04 LTS machine. We also showed you how to install official NVIDIA GPU drivers on Ubuntu Server 22.04 LTS in headless mode (no GUI installed) and how to check if official NVIDIA GPU drivers are installed on Ubuntu Server 22.04 LTS work.

References:

Related Posts