How to Install Nvidia Drivers on Rocky Linux 9/8

Nvidia Drivers are essential for maximizing the performance of Nvidia graphics cards. They connect the operating system with the hardware, enabling applications like gaming, professional rendering, and scientific computation. This guide will demonstrate one of the more popular methods of installing Nvidia Drivers directly from Nvidia CUDA RPM.

Before we continue into the steps, for newer users looking at installing these drivers, here is a list of benefits and key features you can gain:

  1. Integration: Ensures communication between the GPU and the operating system.
  2. Peak Performance: Optimizes graphical and computational tasks for smooth operation.
  3. Future-Proof: Regular updates maintain compatibility with the latest applications and games.
  4. CUDA Support: Enables GPU acceleration for complex computational tasks.
  5. Enhanced Stability: Reduces crashes and bugs for reliable system performance.
  6. Customizable Settings: Allows fine-tuning of graphics settings to match user preferences.
  7. Energy Efficiency: Balances performance and energy consumption.
  8. Extended Support: Offers long-term support for various Nvidia products.

Next, we will demonstrate the steps for installing Nvidia drivers on Rocky Linux 9 or 8, including tips for troubleshooting potential installation issues.

Nvidia Drivers Installation Preparations

Update Rocky Linux Before Nvidia Drivers Installation

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

Identifying Your Graphics Card

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.

Checking the Secure Boot Status

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 setup. Be sure to consult your system documentation or the troubleshooting section if you encounter issues related to secure boot.

Add EPEL Repository For Nvidia Drivers Installation

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.

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.

Finalize NVIDIA Drivers Installation via DNF Commands

Import 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 that the necessary dependencies be installed. 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:

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:

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. Use the command:

reboot

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:

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:

Problem Resolution: Troubleshooting Instructions

These solutions may work, but given the many different system setups, hardware, and potential issues, you may need further research.

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 for troubleshooting 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 update your drivers 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.

Joshua James
Follow me