Install NVIDIA drivers on Ubuntu in under 5 minutes

Akriotis Kyriakos
4 min readDec 4, 2024

--

Install NVIDIA drivers on Ubuntu, minus the drama.

Introduction

The “AI explosion” of the latest years has positioned NVIDIA as a pivotal player in the tech industry due to its dominance in producing GPUs and other hardware crucial for AI workloads. Installing NVIDIA drivers on Linux is often considered a rather complicated task for several reasons, mainly due to differences in Linux distributions, the variety of configurations may encountered, and the need for compatibility with specific hardware and software.

Following the instructions from the official site can drag you down a spiral of dependencies hell (been there; done that; do not recommend) and really put on test your mental stability (there’re even memes out there making fun of the situation; the one with Joachin Phoenix & Joker made me laugh the most).

Check hardware and drivers version

What we need to check first is the existence of a display controller and the version of your currently running driver. For that matter, we are going to execute the command sudo lshw -C display.

The lshw tool provides detailed information about hardware components, and using the argument -C display it filters the output to only show display-related hardware.

When the output starts with a line *-display UNCLAIMED, it indicates that the operating system has detected the hardware (a display controller, such as a GPU) but has not associated it with a functioning driver. This means the device is not currently usable for display purposes, as the necessary driver is either missing, not loaded, or incompatible.

Canonical classifies NVIDIA drivers in two categories: a Unified Driver Architecture (UDA) drivers — recommended for generic desktop use, and the so called Enterprise Ready Drivers (ERD) — recommended for servers and computing tasks. Their packages are decorated with the -server suffix.

Install the drivers

To install the drivers, we will use the recommended Canonical tool, ubuntu-drivers. Since it is not included with the distribution by default, we need to install it first:

sudo apt update
sudo apt install ubuntu-drivers-common

Then you have two options: either let the tool identify and automatically pick the right UDA or ERD driver for you or hand-pick the version you wish to install. As we already said, let’s minimize the drama and go for the automatic way:

For desktop, generic & gaming purposes (UDA) execute:

sudo ubuntu-drivers install 

and for computing purposes on servers (ERD) try:

sudo ubuntu-drivers --gpgpu install

If you want to choose a specific version, you can list the available driver version by executing the following command:

sudo ubuntu-drivers list

All the commands are identical; by adding the --gpgpu flag you are alternating from desktop to server drivers.

Verification

After the installation is complete (it will take a couple of minutes), reboot and let’s check again the output of the lshw command:

sudo lshw -C display

The UNCLAIMED label has now disappeared! Now that the drivers are installed we can additional check the GPU with tooling provided by NVIDIA:

nvidia-smi -L && nvidia-smi

And this is exactly what we wanted to see!

Closing words

A very useful tool that you might need is nvtop, a real-time monitoring tool for systems with NVIDIA GPUs. It provides a terminal-based interface, similar to top and htop for CPU and memory usage, but specifically designed to display detailed information about GPU usage. You can install it with apt:

sudo apt install nvtop

Till the next time…

--

--

Akriotis Kyriakos
Akriotis Kyriakos

Written by Akriotis Kyriakos

talking about: kubernetes, golang, open telekom cloud, aws, openstack, sustainability, software carbon emissions

No responses yet