How to Install NVIDIA Drivers on Rocky Linux EL9 or EL8

NVIDIA, renowned for producing powerful graphics processing units (GPUs), also develops driver software to ensure these high-performance devices function optimally. As a user or developer on Rocky Linux, you may need these drivers, especially if you’re involved in demanding tasks such as machine learning, data analysis, 3D modeling, or high-resolution video processing. The following guide will demonstrate how to install NVIDIA Drivers on Rocky Linux 9 or Rocky Linux 8, ensuring your NVIDIA hardware can perform at its best.

There are several distinct advantages to installing NVIDIA drivers on Rocky Linux via NVIDIA’s RPM for Enterprise Linux distributions. To list a few:

  • Performance Boost: NVIDIA’s proprietary drivers are known to provide better performance than open-source alternatives, such as Nouveau drivers. This enhanced performance can be essential for graphics-intensive tasks or applications.
  • Access to NVIDIA CUDA: Access to NVIDIA CUDA is crucial for those in deep learning or GPU-accelerated computing. CUDA allows direct access to the virtual instruction set and parallel computational elements of the GPU.
  • Consistent Updates: NVIDIA regularly provides updates and bug fixes for their drivers, ensuring your system stays up-to-date with the latest improvements and security patches.
  • Better Support for Games and Applications: Certain games and applications may require or perform better with the specific features and optimizations in the proprietary NVIDIA drivers.

Installing NVIDIA drivers on your Rocky Linux system equates to getting the most out of your NVIDIA GPU, whether you’re a casual user, gamer, or professional developer. It ensures system stability and security and optimizes your Linux experience. The upcoming how-to article will navigate you through the process step-by-step, aiming to make it as straightforward and efficient as possible.

Section 1: Installation Preparations

Step 1: Update Rocky Linux Before Nvidia Drivers Installation on Rocky Linux

The first thing to do before commencing the installation process is to update your system. Doing so will avoid potential conflicts during the installation, often caused by out-of-date packages. To accomplish this task, the command that you need to execute is:

sudo dnf upgrade --refresh

Step 2: Identifying Your Graphics Card on Rocky Linux

As you progress, it’s important to identify the NVIDIA Graphics card installed in your system. Verifying its compatibility will ensure a smooth installation process. However, you can skip this step if you have a newer model, as they are likely supported.

You can use the following command to determine your graphics card model:

lspci | grep -e VGA

This is what an example output may look like:

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

In case you’re using an older card, it’s prudent to conduct a quick check on NVIDIA’s official website. You might need to install legacy drivers if the latest NVIDIA drivers no longer support your card.

Step 3: Checking the Secure Boot Status on Rocky Linux

If you have secure boot enabled, you might encounter issues during the NVIDIA drivers installation. You might need to either disable it or take additional steps to avoid conflicts. Thus, it’s crucial to check the status of the secure boot.

You can use the following command to verify if secure boot is enabled:

mokutil --sb-state

This command will provide output on your terminal, indicating whether the secure boot is active. Depending on your system configuration, you may need to change your system setup. Be sure to consult your system documentation or the troubleshooting section if you encounter issues related to secure boot.

Section 2: Incorporating the EPEL Repository on Rocky Linux

Step 1: Setting Up the EPEL Repository for Nvidia Drivers on Rocky Linux

Our initial task involves the installation of the EPEL repository. It is advisable to incorporate both repositories for the best outcome.

Make sure to choose the appropriate command for your specific version of Rocky Linux. For instance, if you’re using Rocky Linux 9, you should use the EPEL 9 command.

Configuring EPEL for Rocky Linux 9

The first action involves activating the CodeReady Builder (CRB). It can be done using this command:

sudo dnf config-manager --set-enabled crb

Once the CRB is activated, you can install both EPEL versions. Utilize the command below to complete this process:

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

Configuring EPEL for Rocky Linux 8

To setup the EPEL for Rocky Linux 8, you can use 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

In the context of these instructions, we are activating and integrating an additional repository of software packages to your Linux distribution. This will broaden the selection of software you can install and ensure compatibility with your specific Rocky Linux version.

Section 3: Install NVIDIA Drivers on Rocky Linux

Step 1: Integrating Nvidia Drivers RPM

The upcoming process requires the installation of the NVIDIA drivers repository sourced from NVIDIA itself. The reason behind this is the convenience it brings by providing immediate access to newly released updates.

Ensure the repository aligns well with your specific Rocky Linux distribution while importing it into your system.

Adding Nvidia Repository RPM for Rocky Linux 9

Use the command below to incorporate the repository into Rocky Linux 9:

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

Adding Nvidia Repository RPM for Rocky Linux 8

For Rocky Linux 8, the command changes slightly as follows:

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

Following the repository import, it’s recommended to install the necessary dependencies. Some of them might be pre-installed, but running the following command ensures their presence:

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

Once done, it’s time to integrate the most recent NVIDIA drivers using:

sudo dnf module install nvidia-driver:latest-dkms

You might encounter a prompt inquiring about importing GPG keys during this step. Should this happen, respond affirmatively with a “Yes.”

To provide you with an idea of what to expect, below is an image showing an example output from my machine:

Screenshot showing the terminal commands for installing the latest Nvidia drivers on Rocky Linux 9 or 8.Pin
Terminal screenshot demonstrating how to install the latest Nvidia drivers on Rocky Linux.

As an alternative, Nvidia RPM modules can be listed using the command:

sudo dnf module list nvidia-driver

Here’s another image depicting an example output from this process:

Screenshot displaying a list of modules for Nvidia drivers on Rocky Linux 9 or 8.Pin
Use these commands to list all the Nvidia driver modules on your Rocky Linux system.

You might consider installing this module instead of the proprietary one if you’re an open-source user. However, feedback indicates that open-source users might encounter bugs depending on the graphics card. If this occurs, switch to the proprietary drivers. Based on user feedback, this switch typically resolves the issue.

For instance:

sudo dnf module install nvidia-driver:open-dkms

After successful completion, a system restart is necessary. Simply use the command:

reboot

Section 4: Confirming the NVIDIA Drivers Installation

Execution of NVIDIA-SMI Command

To ascertain the successful installation of the NVIDIA drivers, execute the NVIDIA-SMI command as shown below:

nvidia-smi

This command provides you with an output that serves as evidence of the successful installation. Here is an image to help you anticipate what you should be seeing:

Screenshot of Nvidia-SMI command output showing Nvidia driver status on Rocky Linux 9 or 8.Pin
Example output of the Nvidia-SMI command, confirming successful Nvidia driver installation on Rocky Linux.

Accessing NVIDIA Settings

An alternate way to verify the installation is by accessing the NVIDIA settings GUI. This can be accomplished either from the application icon menu or via the command as shown below:

nvidia-settings

Locating the GUI Application Icon

Another route to verification lies in accessing the GUI application icon. This can be done by following the path: Activities > Show Applications > NVIDIA X SERVER within the application menu.

To give you a better understanding of what a successful NVIDIA drivers installation looks like, refer to the following image:

Screenshot of Nvidia Settings GUI displaying system information and graphics card stats on Rocky Linux 9 or 8.Pin
Navigate the Nvidia Settings GUI to view your graphics card’s system information and performance stats.

As previously mentioned, NVIDIA 525 is the most recent version when 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.

Problem Resolution: Troubleshooting Instructions

These solutions may work, given the many different system setup, hardware and potential issues, you may need to do further research.

Procedure 1: Addressing Secure Boot Issues with Nvidia Driver Installation

If you’ve installed the NVIDIA drivers and are encountering problems due to Secure Boot, it may be possible to resolve these without disabling Secure Boot. Please follow these steps:

Disabling Nouveau Drivers

Nouveau drivers can cause conflicts with NVIDIA drivers. To prevent these issues, use the following commands to blacklist the Nouveau drivers:

echo "blacklist nouveau" | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
echo 'omit_drivers+=" nouveau "' | sudo tee /etc/dracut.conf.d/blacklist-nouveau.conf

Once you’ve made these modifications, regenerate all Dracut initramfs images and update the module dependency list with these commands:

sudo dracut --regenerate-all --force
sudo depmod -a

Activating Secure Boot

Should Secure Boot be enabled on your system, importing the Machine Owner Key (MOK) public key will be necessary. This key signs the NVIDIA kernel module. To do this, use the mokutil command:

sudo mokutil --import /var/lib/dkms/mok.pub

The mokutil command will prompt you to create a password, which you’ll use during the system reboot.

Following this, reboot your system:

sudo reboot

During the reboot, your system may ask for key enrollment. Confirm this request and enter the password you created with the mokutil command.

Checking the Driver Installation

To confirm that the NVIDIA drivers have been successfully installed, run the nvidia-smi command:

nvidia-smi

Post-Windows Update Troubleshooting

A firmware update may reset the TPM chip in a dual boot scenario with Windows. You must re-import the Machine Owner Key (MOK) if this occurs. To resolve this, repeat the mokutil command:

sudo mokutil --import /var/lib/dkms/mok.pub

These instructions provide a step-by-step guide through the troubleshooting process to resolve any potential issues you may encounter while installing the NVIDIA drivers.

Conclusion

Installing NVIDIA drivers on Rocky Linux 9 or 8 can be challenging, especially when considering variables like Secure Boot and the Nouveau drivers. However, we’ve aimed to simplify this process for you in this comprehensive guide, detailing each step in an understandable and actionable manner. Whether dealing with conflicts from the Nouveau drivers or managing Secure Boot, the steps provided should enable you to install the NVIDIA drivers successfully.

Our final recommendation is to keep your drivers updated to the latest version to ensure optimal performance and security. Regular updates can prevent many issues before they occur, so it’s worth checking for new versions periodically.

Comments are closed.

Share to...