CentOS

Install NVIDIA Drivers on CentOS Stream 9

“If you have installed CentOS Stream 9 on your computer and have an NVIDIA GPU installed on your computer, installing the NVIDIA GPU drivers on CentOS Stream 9 is the first thing you want to do.

In this article, I will show you how to install NVIDIA GPU drivers on CentOS Stream 9. So, let’s get started.”

Table of Contents

  1. Checking if the System Has Any NVIDIA GPU Installed
  2. Disable Secure Boot from the BIOS
  3. Enabling the EPEL Repository on CentOS Stream 9
  4. Installing the Required Dependencies and Build Tools for Compiling NVIDIA Kernel Modules
  5. Adding the Official NVIDIA CUDA Package Repository on CentOS Stream 9
  6. Installing the Latest NVIDIA GPU Drivers on CentOS Stream 9
  7. Checking If NVIDIA Drivers are Installed Properly
  8. Conclusion
  9. References

Checking if the System has any NVIDIA GPU Installed

You can check whether your computer has an NVIDIA GPU installed with the following command:

$ lspci | egrep 'VGA|3D'

As you can see, I have an NVIDIA GeForce GTX 1050 Ti GPU installed on my computer. You may have a different NVIDIA GPU installed.

By default, the open-source Nouveau GPU drivers are used1 instead of the proprietary NVIDIA GPU drivers2 on CentOS Stream 9. Once you install the proprietary NVIDIA GPU drivers, you will see that they are used instead of the open-source Nouveau GPU drivers.

$ lsmod | grep nouveau
$ lsmod | grep nvidia

Disable Secure Boot From the BIOS

For NVIDIA GPU drivers to work on CentOS Stream 9, you must disable secure boot from the BIOS of your motherboard if it uses the UEFI firmware for booting operating systems.

The process of disabling secure boot from the BIOS of UEFI-capable motherboards is vendor-specific (different for each motherboard vendor like ASUS, MSI, Gigabyte, AsRock, etc.). So, it’s best to check the user manual of your motherboard to find out how to disable secure boot on your motherboard.

For older BIOS-based motherboards, you don’t need to do anything for the NVIDIA GPU drivers to work on CentOS Stream 9.

Enabling the EPEL Repository on CentOS Stream 9

To install the NVIDIA GPU drivers on CentOS Stream 9, you will have to install the required build tools and the required dependency libraries for compiling the NVIDIA kernel modules. Some of these are available in the CentOS Stream 9 EPEL repository. In this section, I am going to show you how to enable the EPEL repository on CentOS Stream 9.

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

$ sudo dnf makecache

Enable the official CentOS Stream 9 CRB package repository with the following command:

$ sudo dnf config-manager --set-enabled crb

Install the epel-release and epel-next-release packages with the following command:

$ sudo dnf install epel-release epel-next-release

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

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

The epel-release and the epel-next-release packages should be installed, and the EPEL repository should be enabled.

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

$ sudo dnf makecache

Installing the Required Dependencies and Build Tools for Compiling NVIDIA Kernel Modules

To install the required build tools and the required dependency libraries for compiling the NVIDIA kernel modules, run the following command:

$ sudo dnf install kernel-headers-$(uname -r) kernel-devel-$(uname -r) tar bzip2 make automake gcc gcc-c++ pciutils elfutils-libelf-devel libglvnd-opengl libglvnd-glx libglvnd-devel acpid pkgconfig dkms

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

The required packages are being downloaded from the internet. It will take a while to complete.

Once the packages are downloaded, you will be asked to confirm the GPG key of the CentOS official package repository.

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

To confirm the GPG key of the EPEL repository, press Y and then press <Enter>.

The installation should continue.

At this point, the required dependency libraries and build tools for compiling the NVIDIA kernel module should be installed.

Adding the Official NVIDIA CUDA Package Repository on CentOS Stream 9

To add the official NVIDIA CUDA package repository on CentOS Stream 9, run the following command:

$ sudo dnf config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel9/$(uname -i)/cuda-rhel9.repo

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

$ sudo dnf makecache

Installing the Latest NVIDIA GPU Drivers on CentOS Stream 9

To install the latest version of the NVIDIA GPU drivers on CentOS Stream 9, run the following command:

$ sudo dnf module install nvidia-driver:latest-dkms

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

All the NVIDIA GPU drivers packages and the required dependency packages are being downloaded from the internet. It will take a while to complete.

Once the packages are downloaded, you will be asked to confirm the GPG key of the official NVIDIA package repository. Press Y and then press <Enter> to confirm the GPG key.

The installation should continue. It will take a while to complete.

The installation should continue. It will take a while to complete.

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

$ sudo reboot

Checking if NVIDIA Drivers are Installed Properly

Once your computer boots, you should see that the proprietary NVIDIA GPU drivers are used1 instead of the open-source Nouveau GPU drivers2.

$ lsmod | grep nvidia
$ lsmod | grep nouveau

You should also find the NVIDIA X Server Settings app in the Application Menu of CentOS Stream 9. Click on it.

The NVIDIA X Server Settings app should run without any errors, and it should show a lot of information related to your installed NVIDIA GPU.

You should also be able to run the NVIDIA command-line programs like nvidia-smi.

$ nvidia-smi

Conclusion

In this article, I have shown you how to add the official NVIDIA CUDA repository on CentOS Stream 9. I have also shown you how to install the latest version of the proprietary NVIDIA GPU drivers on CentOS Stream 9.

References

  1. Extra Packages for Enterprise Linux (EPEL) :: Fedora Docs (fedoraproject.org)
  2. NVIDIA Driver Installation Quickstart Guide :: NVIDIA Tesla Documentation

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.