How to Install NVIDIA Drivers on Rocky Linux 9

For the most part, the NVIDIA driver pre-installed in the Nouveau open-source graphics device driver for NVIDIA video cards is acceptable; however, if you are using your Linux system for graphical design or gaming, you may get better drivers. The Nouveau drivers are community-created and -supported drivers that are available free of charge and are an open-source alternative to the NVIDIA proprietary drivers.

Nouveau’s primary goal is institutional energy efficiency while providing excellent performance. However, power users may find essential features, like support for the latest 3D APIs or SLI/Crossfire support, often left out due to power issues. This is where the proprietary NVIDIA drivers come in. The NVIDIA driver is a closed-source driver produced by NVIDIA for use on systems with an NVIDIA graphics card. These drivers usually offer better performance, more reliable stability, and greater compatibility with newer software releases than Nouveau. If you use your Linux system for graphical design or gaming, you should consider using the NVIDIA driver.

The following tutorial will teach you how to install the NVIDIA drivers on Rocky Linux 9 using the command line terminal with Nvidia’s Cuda repository for the latest version.

Update Rocky Linux

Before you begin, update your system to ensure all existing packages are up to date to avoid conflicts during the installation.

sudo dnf upgrade --refresh -y

Determine your Graphics Card

The first step for users with aging NVIDIA Graphics cards is to determine what it is and if it is supported, users with brand new cards can skip this part as there is no doubt they will be supported.



First, find your graphics card module.

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.

Install EPEL/EPEL Next Repository (Required)

The first task is to install the EPEL repository, and the recommendation is to install both repositories.

First, enable the CRB repository.

sudo dnf config-manager --set-enabled crb

Next, install EPEL using the following (dnf) terminal command.



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

Install NVIDIA Drivers – NVIDIA Repository Method

WARNING, X86_64 ARCHITECTURE IS ONLY SUPPORTED IN THIS METHOD FROM NVIDIA.

The second method is installing the NVIDIA drivers directory from the source. This can be beneficial, along with the ability to grab updates as soon as they appear. Beta drivers are also available in this repository, making it possibly more appealing than using RPM Fusion, which often breaks desktops and servers compared to the Nvidia Method.

First, import the repository for your system.

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

Install required dependencies for safe measures.

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 latest NVIDIA drivers.

sudo dnf module install nvidia-driver:latest-dkms

Example output:



How to Install NVIDIA Drivers on Rocky Linux 9

Note you will be prompted to import GPG keys during the installation. This is safe to do so for newer users, type Y when prompted.

Alternatively, you can list the modules of Nvidia RPM using the following command.

sudo dnf module list nvidia-driver

For open-source users, you can install this module instead of the proprietary, and I suggest keeping the latest. However, as mentioned above, this is still new so issues may be encountered possibly slightly more, but this should be rare. Any problems, install the non-open source.

Example:

sudo dnf module install nvidia-driver:open-dkms

Lastly, reboot your system once done.

reboot

Verify the installation by running NVIDIA-SMI as the manual installation steps showed beforehand.



nvidia-smi

Example output:

How to Install NVIDIA Drivers on Rocky Linux 9

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

nvidia-settings

Example output:

How to Install NVIDIA Drivers on Rocky Linux 9

As mentioned above, at the time of the tutorial, NVIDIA 515 is the latest, which you can see is installed due to the fact we are installing directly from the NVIDIA repository; in the future, this version will change pretty quickly as the tutorial ages.

Troubleshoot

Slow Boot Times with Nvidia Drivers

A common complaint when installing Nvidia drivers is the slow boot time. This is mainly caused due to Nvidia, with the kernel searching for USB-C drivers that support VR devices.

Depending on your system setup, the following methods may work to fix it.



BIOS:

Blacklist the USB-C driver by opening the following “/etc/sysconfig/grub” location.

nano /etc/sysconfig/grub

Find the line with “GRUB_CMDLINE_LINUX=” and add the following as the last entry under it.

rd.driver.blacklist=i2c-nvidia-gpu

Refresh grub.

grub2-mkconfig -o /boot/grub2/grub.cfg

Then reboot your system.

reboot

UEFI:

Blacklist the USB-C driver

sudo echo "blacklist i2c_nvidia_gpu" >> /etc/modprobe.d/blacklist_i2c-nvidia-gpu.conf

Refresh grub.



sudo grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg

Then reboot your system.

reboot

Comments and Conclusion

In my opinion, using the NVIDIA repository is the go-to if you are looking for a more powerful graphics card and drivers. Installing these drivers can be a bit daunting for new Linux users, but the reward is worth it for better performance.


Not what you were looking for? Try searching for additional tutorials.

Leave a Comment