Debian

How to Install the NVIDIA GPU Drivers on a Headless Debian 11

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

In this article, we will show you how to install the official NVIDIA GPU drivers on a headless Debian 11 server machine.

Topic of Contents:

  1. Connecting to the Debian 11 Server Machine via SSH
  2. Checking If the NVIDIA GPU Is Installed
  3. Enabling the Contrib and Non-Free Package Repositories on Debian 11
  4. Installing the NVIDIA Drivers on Headless Debian 11 Server
  5. Checking If the NVIDIA Drivers Are Installed Correctly on the Debian 11 Server
  6. Uninstalling the NVIDIA Drivers from Debian 11
  7. Conclusion
  8. References

Connecting to the Debian 11 Server Machine via SSH

Connecting to your Debian 11 server machine via SSH is optional if you have access to the server hardware (where you installed the Debian 11). You can just attach a mouse, a keyboard, and a monitor to the server and install the NVIDIA drivers on it.

If you don’t have access to the Debian 11 server hardware, you need to SSH into it to install the NVIDIA drivers.

To SSH into your Debian 11 server machine, you can run the following command from a terminal app of your desktop/laptop from which you want to access it:

$ ssh <username>@<hostname/ip-address>

Make sure to replace the <username> and <hostname/ip-address> with the login username and domain name or the IP address of your Debian 11 server machine, respectively.

If you’re using the Windows 10 or Windows 11 and you need any assistance in connecting to your Debian 11 server machine via SSH, read the article on How to SSH into the Linux Servers from Windows 10/11.

Checking If the NVIDIA GPU Is Installed

To check whether you have an NVIDIA GPU installed on your Debian 11 server machine, run the following command:

$ lspci -nn | egrep -i '3d|display|vga'

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

Also, from the output of the following commands, you can see that the open-source nouveau drivers are 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 Debian 11 server.

$ lsmod | grep nvidia

$ lsmod | grep nouveau

Enabling the Contrib and Non-Free Package Repositories on Debian 11

To install the official NVIDIA drivers on your Debian 11 server, you need to enable the contrib and non-free package repositories on your Debian 11 server.

To easily manage the official Debian 11 package repositories, you can use the apt-add- command repository. This command may not be available by default on your Debian 11 server. But, you can easily install it from the official package repository of Debian 11.

First, update the APT package repository cache with the following command:

$ sudo apt update

Then, install the software-properties-common package with the following command:

$ sudo apt install software-properties-common

To confirm the installation, press Y and then press <Enter>.

The software-properties-common package and the required dependency packages are being installed. It takes a while to complete.

The software-properties-common package and the required dependency packages are installed at this point.

To enable the official Debian 11 contrib package repository, run the following command:

$ sudo apt-add-repository contrib

The official Debian contrib package repository should be enabled.

To enable the official Debian 11 non-free package repository, run the following command:

$ sudo apt-add-repository non-free

The official Debian non-free package repository should be enabled.

For the changes to take effect, update the APT package repository cache with the following command:

$ sudo apt update

Installing the NVIDIA Drivers on Headless Debian 11 Server

To install the official NVIDIA drivers on your headless Debian 11 server, run the following command:

$ sudo apt install nvidia-driver firmware-misc-nonfree

To confirm the installation, press Y and then press <Enter>.

The NVIDIA drivers packages and the required dependency packages are being downloaded. It takes a while to complete.

The NVIDIA drivers packages and the required dependency packages are being installed. It takes a while to complete.

Once you see the following window, press <Tab> to select OK. Then, press <Enter>.

The installation of the NVIDIA drivers packages should continue. The installation should be finished shortly.

Once the NVIDIA drivers are installed, restart your Debian 11 server machine for the changes to take effect.

$ sudo reboot

Checking If the NVIDIA Drivers Are Installed Correctly on the Debian 11 Server

Once your Debian 11 server boots, you can verify that the NVIDIA kernel modules are used instead of the open-source nouveau kernel modules with the following commands. So, the official NVIDIA GPU drivers are working just fine:

$ lsmod | grep nouveau

$ lsmod | grep nvidia

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

$ nvidia-smi

Uninstalling the NVIDIA Drivers from Debian 11

If you want to uninstall the NVIDIA drivers from your Debian 11 server and you need any assistance, read the article on How to Clean Install the NVIDIA Drivers on Debian 11.

Conclusion

We showed you how to enable the contrib and non-free package repositories on a headless Debian 11 server. We also showed you how to install the official NVIDIA drivers on a headless (no graphical user interface installed) Debian 11 server and how to verify if the official NVIDIA GPU drivers are working on the Debian 11 server.

References:

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.