How to Install NVIDIA Drivers on Rocky Linux EL9 or EL8


Nvidia graphics drivers allow Linux users to enjoy an unparalleled experience running graphical applications and games on their systems. For instance, they provide a stable environment for Nvidia GPUs and keep up with the necessary changes by including support for the newest releases of OpenGL and CUDA. To ensure Linux users can take full advantage of what’s available, this guide walks you through installing such drivers on Rocky Linux 9 or Rocky Linux 8. Whether you’re a gamer who needs better frame rates or a professional designer who relies on computing power, having up-to-date Nvidia drivers will always give you the best experience.

Step 1: Update Rocky Linux

Before proceeding with the installation, update your system to ensure that all existing packages are up-to-date to prevent any conflicts during the process.

sudo dnf upgrade --refresh

Step 2: Determine your Graphics Card

Before moving forward, checking what NVIDIA Graphics card you have is recommended to ensure it is supported. Those with newer cards can skip this step, as they will most likely be supported.

To determine your graphics card model, use the following command.

lspci | grep -e VGA

Example output:

03:00.0 VGA compatible controller: NVIDIA Corporation TU117 [GeForce GTX 1650] (rev a1)

If you are using an old card, I advise you to research it on the NVIDIA website; if the latest NVIDIA drivers still support it, you may need to install legacy drivers.

Step 2: Install EPEL Repository

The first task is to install the EPEL repository, and the recommendation is to install both repositories. Ensure you install the correct EPEL repository to match your Rocky Linux distribution.

Import EPEL for Rocky Linux 9

First, activate the CRB.

sudo dnf config-manager --set-enabled crb

With the CRB activated, execute the following command to install both versions of EPEL.

sudo dnf install \
    https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \
    https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm

Import EPEL for Rocky Linux 8

Activate the Rocky Linux 8 EPEL with the following command.

sudo dnf install \
    https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
    https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-8.noarch.rpm

Step 3: Install NVIDIA Drivers

Proceed by installing the NVIDIA drivers repository from NVIDIA. This can be advantageous as it allows easy access to updates as soon as they are released.

First, import the repository for your system, and ensure that you match the correct repository to your Rocky Linux distribution.

Import Nvidia Repository RPM for Rocky Linux 9:

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

Import Nvidia Repository RPM for Rocky Linux 9:

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

Install necessary dependencies, they may already be installed, but it is advisable to run the command to ensure all are present.

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

Next, install the most recent NVIDIA drivers.

sudo dnf module install nvidia-driver:latest-dkms

Example output when I installed Nvidia drivers on my machine:

Please note that during the installation, you may be prompted to import GPG keys which you will need to answer with “Yes.”

See also
How to Install Apache Cassandra on Rocky Linux EL9 or EL8

An alternate way is to list the Nvidia RPM modules using the following command.

sudo dnf module list nvidia-driver

Example output:

You can install this module instead of the proprietary one for open-source users. Still, from the feedback I have received on many distributions of users trying to install the open-source option, it can have bugs depending on the card. If this occurs, install the proprietary drivers, as these will work again from the feedback I received from users switching from the open-source version to the proprietary.

Example:

sudo dnf module install nvidia-driver:open-dkms

Finally, restart your system once completed.

reboot

Step 4: Verify NVIDIA Drivers Installation

Verify the installation by executing the NVIDIA-SMI command.

nvidia-smi

Example output:

Alternatively, you can access the NVIDIA settings GUI from the application icon menu or use the following command.

nvidia-settings

Another option is to open the GUI application icon by navigating to the path Activities > Show Applications > NVIDIA X SERVER in the application menu.

Example output of successfully installed Nvidia Drivers:

As previously mentioned, NVIDIA 525 is the most recent version at the time of writing this tutorial. By installing directly from the NVIDIA repository, it can be seen that it is installed. However, please note that this version number may change quickly as the tutorial becomes dated, but the process is the same.

Conclusion

Installing Nvidia drivers on Rocky Linux can significantly improve performance and access to advanced features compared to using the open-source Nouveau driver. The Nvidia driver is optimized explicitly for Nvidia GPUs and provides support for the latest OpenGL and CUDA versions. The driver also supports multiple monitors, 3D graphics, and video acceleration. Additionally, by installing the Nvidia driver directly from the Nvidia repository, you can be sure that you are always running the latest version of the driver, which can help to ensure optimal performance. The Nouveau driver is not as stable, updated, or optimized for performance. Installing Nvidia drivers on Rocky Linux is recommended for users who want the best performance and features from their Nvidia GPU.

2 thoughts on “How to Install NVIDIA Drivers on Rocky Linux EL9 or EL8”

  1. Hi Joshua, I want to thank you for writing up a great article on how to install nvidia drivers on rocky linux 9. I just installed rocky linux 9 on my desktop and was looking to install the nvidia drivers since I have a 1060 geforce GTX card. The instructions work very well and I did not have to make any changes at all. However, you may want to add a reboot after the “sudo dnf upgrade –refresh -y” command to make sure that the “uname -r” matches what the system is booting into at the time of the driver install. The kernel-devel-* and the kernel-header-* did not coincide with what was available in the repo and therefore will not install with all the dependencies if the upgrade found a newer version of the kernel. I had to play around to figure that out. A reboot at the upgrade step in the beginning will solve this problem.

    thanks again
    p

    Reply

Leave a Comment

Share to...