How to Install or Upgrade Nvidia Drivers on Rocky Linux 8

Most modern Linux Desktop systems come with an Nvidia driver pre-installed in the Nouveau open-source graphics device driver for Nvidia video cards. For the most part, this is acceptable; however, if you are using your Linux system for graphical design or gaming, you may get better drivers.

Historically, the Nouveau proprietary drivers are slower than Nvidia’s proprietary drivers, along with lacking the newest features, software technology, and support for the latest graphics card hardware. In most situations, upgrading your Nvidia Drivers using the following guide is more beneficial than not doing it. In some cases, you may see some substantial improvements overall.

In the following guide, you will know how to install Nvidia drivers on your Rocky Linux 8 desktop.

Prerequisites

  • Recommended OS: Rocky Linux 8.+.
  • User account: A user account with sudo or root access.

Update Operating System

Update your Rocky Linux operating system to make sure all existing packages are up to date:

sudo dnf upgrade --refresh -y

The tutorial will be using the sudo command and assuming you have sudo status.


To verify sudo status on your account:

sudo whoami

Example output showing sudo status:

[joshua@rockylinux ~]$ sudo whoami
root

To set up an existing or new sudo account, visit our tutorial on How to Add a User to Sudoers on Rocky Linux.

To use the root account, use the following command with the root password to log in.

su

Install Nvidia Drivers for Rocky Linux

Preinstall Dependecies

The following installation is designed for the default Rocky Linux 8 kernel; any modified Linux Kernel installations may not work.

The first step is to import the repository from EPEL (Extra Packages for Enterprise Linux) as follows:


sudo dnf install epel-release -y

Next, add the Nvidia repository:

sudo dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo

Example output:

Adding repo from: https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo

The second step is to install the kernel-devel and headers that the Nvidia drivers will utilize:

sudo dnf install kernel-devel-$(uname -r) kernel-headers-$(uname -r)

Example output:

How to Install or Upgrade Nvidia Drivers on Rocky Linux 8

Type “Y,” then press the “ENTER KEY” to proceed.

Install Nvidia Drivers

Now with the repository added, you can proceed to install the latest Nvidia stable driver as follows:


sudo dnf install nvidia-driver nvidia-settings

Example output:

How to Install or Upgrade Nvidia Drivers on Rocky Linux 8

Type “Y,” then press the “ENTER KEY” to proceed.

Note, during the installation, you will be prompted to import the GPG key as follows:

Total                                                                    19 MB/s | 230 MB     00:12     
warning: /var/cache/dnf/cuda-rhel8-x86_64-f1d7a46f058da57c/packages/dnf-plugin-nvidia-2.0-1.el8.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 7fa2af80: NOKEY
cuda-rhel8-x86_64                                                       9.2 kB/s | 1.6 kB     00:00    
Importing GPG key 0x7FA2AF80:
 Userid     : "cudatools <cudatools@nvidia.com>"
 Fingerprint: AE09 FE4B BD22 3A84 B2CC FCE3 F60F 4B3D 7FA2 AF80
 From       : https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/7fa2af80.pub
Is this ok [y/N]: 

Optionally you can also install the CUDA drivers:

sudo dnf install cuda-driver

Example output:

How to Install or Upgrade Nvidia Drivers on Rocky Linux 8

Type “Y,” then press the “ENTER KEY” to proceed.


Once installed, reboot your Rocky Linux desktop:

reboot now

After the restart, verify the installation worked by running the following command:

nvidia-smi

Example output:

How to Install or Upgrade Nvidia Drivers on Rocky Linux 8

As you can see, the information on the graphics card is now present. If you cannot see any information on your Nvidia card, it means the installation was not successful. You will need to repeat the steps or investigate why; typically, most issues occur with modified systems other than the default.

Alternatively, install Neofetch to print out a fancy printout of your system with EPEL repository on your system.

sudo dnf install neofetch -y

Print your system specs with neofetch.


neofetch

Example output:

How to Install or Upgrade Nvidia Drivers on Rocky Linux 8

How to Update Nvidia Drivers

To check for updates and to apply, all you need to do is run the dnf upgrade command as follows:

sudo dnf upgrade --refresh

If an update is available for Nvidia drivers, upgrade.

How to Remove (Uninstall) Nvidia Drivers

To remove the Nvidia drivers with all dependencies and extras installed, run the following command:

sudo dnf remove nvidia-driver nvidia-settings cuda-driver kernel-devel-$(uname -r) kernel-headers-$(uname -r)
Transaction Summary
================================================================================
Remove  40 Packages

Freed space: 739 M
Is this ok [y/N]:

Type “Y,” then press the “ENTER KEY” to proceed.

Comments and Conclusion

In the tutorial, you have learned how to install Nvidia drivers on the Rocky Linux 8 desktop. Ideally, most hardcore gamers would probably not use Rocky Linux as their preferred gaming distribution; however, for systems that have Nvidia GPUs and work with graphics, this can be most excellent to install for better driver support.



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

7 thoughts on “How to Install or Upgrade Nvidia Drivers on Rocky Linux 8”

  1. $ nvidia-smi
    NVIDIA-SMI couldn’t find libnvidia-ml.so library in your system. Please make sure that the NVIDIA Display Driver is properly installed and present in your system.
    Please also try adding directory that contains libnvidia-ml.so to your system PATH.

    Reply
    • Hi Jari,

      I reset my test machine with an Nvidia card with a new rocky Linux 8 desktop, still works fine. I have installed Nvidia 495, the latest release that has just come out of beta.

      Did you reboot the system? I got the error when not rebooting.

      Did you install the Cuba support as well?

      Did you follow the guide strictly? Using an alternative desktop manager or kernel, by any chance? If so, what is it?

      I updated the tutorial with a screenshot of nvidia smi, it definitely works just need to figure out what went wrong on your end.

      Thanks

      Thanks.

      Reply
  2. After version 510 NVIDIA driver, the drivers dind’t work and also nvidia-smi fails as below:
    $ nvidia-smi

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    WARNING:

    You should always run with libnvidia-ml.so that is installed with your
    NVIDIA Display Driver. By default it’s installed in /usr/lib and /usr/lib64.
    libnvidia-ml.so in GDK package is a stub library that is attached only for
    build purposes (e.g. machine that you build your application doesn’t have
    to have Display Driver installed).
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    Linked to libnvidia-ml library at wrong path : /usr/local/cuda-10.1/targets/x86_64-linux/lib/stubs/libnvidia-ml.so

    NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    WARNING:

    You should always run with libnvidia-ml.so that is installed with your
    NVIDIA Display Driver. By default it’s installed in /usr/lib and /usr/lib64.
    libnvidia-ml.so in GDK package is a stub library that is attached only for
    build purposes (e.g. machine that you build your application doesn’t have
    to have Display Driver installed).
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    $ neofetch
           #####          jari@cosmo
          #######         ———-
          ##O#O##         OS: Rocky Linux release 8.5 (Green Obsidian) x86_64
          #######         Host: HP ENVY Laptop 17-ce0xxx
        ###########       Kernel: 4.18.0-348.12.2.el8_5.x86_64
       #############      Uptime: 4 mins
      ###############     Packages: 1957 (rpm)
      ################    Shell: bash 4.4.20
     #################    Resolution: 1680×1050
    #####################  DE: GNOME 3.32.2
    #####################  WM: Mutter
     #################    WM Theme: Adwaita
                           Theme: ZorinBlue-Light [GTK2/3]
                           Icons: ZorinBlue-Light [GTK2/3]
                           Terminal: gnome-terminal
                           CPU: Intel i7-8565U (8) @ 4.600GHz
                           GPU: Intel WhiskeyLake-U GT2 [UHD Graphics 620]
                           GPU: NVIDIA GeForce MX250
                           Memory: 4079MiB / 15561MiB

    Reply
    • Hi Jari,

      Did you install CUDA? If not, please install and re-try, this can solve the issue I think.

      I have not tested the new 510 drivers myself on Rocky Linux or variants of its type but I will soon if you can let me know in the meantime that would be great.

      Thanks,

      Reply
  3. Hi,
    I just did a clean install of Rocky 8.5 on my desktop with a GTS1650s card.
    The installation went perfectly and then I found your tutorial to install the Nvidia drivers.
    I followed (copied and pasted) all the commands and everything went fine, just 1 reboot at the end and it was done.
    Also, the settings persist across re-boots which is more than can be said for Mint / Debian on this same machine!

    Reply

Leave a Comment