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.
Table of Contents
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:
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:
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:
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:
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 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.