Debian

How to Install NVIDIA GPU Drivers on Debian 12 “Bookworm”

If you have an NVIDIA GPU installed on your computer, installing the NVIDIA GPU drivers is the first thing you would want to do after installing the Debian 12 “Bookworm” on your computer.

In this article, we will show you how to install the NVIDIA GPU drivers on Debian 12 “Bookworm”. So, let’s get started.

Topic of Contents:

  1. Enabling the Contrib and Non-Free Repositories on Debian 12
  2. Checking If NVIDIA GPU Is Installed on Your Debian 12 Machine
  3. Updating the Debian 12 Package Database Cache
  4. Installing the Linux Kernel Headers on Debian 12
  5. Installing the NVIDIA GPU Drivers on Debian 12
  6. Checking If the NVIDIA GPU Drivers Are Installed on Debian 12
  7. Conclusion
  8. References

Enabling Contrib and Non-Free Repositories on Debian 12

On Debian 12 “Bookworm”, the official main and non-free-firmware package repositories are enabled by default. To install the NVIDIA GPU drivers and the required dependency packages on Debian 12 “Bookworm”, you have to enable the official Debian 12 contrib and non-free package repositories as well.

To learn how to enable the contrib and non-free package repositories on Debian 12 “Bookworm”, read the article on How to Enable the contrib and non-free Repositories on Debian 12.

Checking If NVIDIA GPU Is Installed on Your Debian 12 Machine

You can check whether your Debian 12 machine has an NVIDIA GPU installed with the following command:

$ lspci | egrep 'VGA|NVIDIA'

As you can see, we have an NVIDIA GeForce GTX 1050 Ti GPU installed on my Debian 12 machine. You may have a different NVIDIA GPU installed.

A screenshot of a computer Description automatically generated

Debian 12 uses the open-source Nouveau GPU drivers by default if you have an NVIDIA GPU installed on your computer as you can see in the following screenshot:

$ lsmod | grep nvidia

$ lsmod | grep nouveau

A screenshot of a computer Description automatically generated

Updating the Debian 12 Package Database Cache

To update the Debian 12 package database cache, run the following command:

$ sudo apt update

A screenshot of a computer Description automatically generated

Installing the Linux Kernel Headers on Debian 12

For the NVIDIA GPU Drivers kernel modules to be compiled on Debian 12, you need to have the Linux Kernel Headers installed on your Debian 12 machine.

To install the Linux Kernel Headers on Debian 12, run the following command:

$ sudo apt install linux-headers-$(uname -r)

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

A screenshot of a computer Description automatically generated

The Linux Kernel Headers and the required dependency packages are being downloaded. It takes a while to complete.

A screenshot of a computer Description automatically generated

The Linux Kernel Headers and the required dependency packages are being installed. It takes a while to complete.

A screenshot of a computer Description automatically generated

At this point, the Linux Kernel Headers should be installed on your Debian 12 machine.

A screenshot of a computer Description automatically generated

Installing the NVIDIA GPU Drivers on Debian 12

To install the NVIDIA GPU drivers on your Debian 12 machine, run the following command:

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

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

A screenshot of a computer Description automatically generated

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

A screenshot of a computer Description automatically generated

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

A screenshot of a computer program Description automatically generated

Press <Enter> once you see this prompt.

A screenshot of a computer Description automatically generated

At this point, the NVIDIA GPU Drivers should be installed on your Debian 12 machine.

A screenshot of a computer Description automatically generated

For the changes to take effect, reboot your Debian 12 machine with the following command:

$ sudo reboot

Checking If the NVIDIA GPU Drivers Are Installed on Debian 12

Once your Debian 12 machine boots, you should see that Debian 12 is using the NVIDIA kernel modules instead of the open-source Nouveau kernel modules. It means that the NVIDIA GPU drivers are installed correctly and working as it should.

$ lsmod | grep nouveau

$ lsmod | grep nvidia

A screenshot of a computer Description automatically generated

The “nvidia-smi” command can also be used to verify whether the NVIDIA GPU drivers are working correctly on Debian 12. If it is, the Debian 12 processes that are using the NVIDIA GPU should be listed. A lot of usage information on your NVIDIA GPU should also be listed.

A screenshot of a computer Description automatically generated

You will find a new app which is the NVIDIA X Server Settings in the “Application Menu” of your Debian 12 desktop once the NVIDIA GPU drivers are installed as well. Click on the NVIDIA X Server Settings icon to open it.

A screenshot of a computer Description automatically generated

The NVIDIA X Server Settings app should be opened. If the NVIDIA GPU drivers are working correctly, you will see a lot of information on your NVIDIA GPU in the NVIDIA X Server Settings app.

A screenshot of a computer Description automatically generated

Conclusion

We showed you how to install the NVIDIA GPU drivers on the Debian 12 “Bookworm” desktop. We also showed you how to check if the NVIDIA GPU drivers are working correctly on Debian 12.

References:

https://wiki.debian.org/NvidiaGraphicsDrivers

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.