The following tutorial will teach you how to install the NVIDIA drivers on CentOS 9 or 8 Stream using the command line terminal using the Nvidia CUDA repository so you have the latest version of Nvidia Drivers installed on your system.
WARNING, X86_64 ARCHITECTURE IS ONLY SUPPORTED IN THIS METHOD FROM NVIDIA. Please also note ancient graphic cards will not benefit from installing the latest packages from Nvidia. Most often, using the default drivers on your system is best for stability and security.
Recommended Steps Before Installation
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
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.
Import Nvidia Repository on CentOS Stream
First, import the repository for your system. Again as with EPEL, ensure you import the correct repository for your version of CentOS.
Import Nvidia Drivers Repository for CentOS 9 Stream
sudo dnf config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel9/$(uname -i)/cuda-rhel9.repo
Import Nvidia Drivers Repository for CentOS 8 Stream
sudo dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/$(uname -i)/cuda-rhel8.repo
Install NVIDIA Drivers on CentOS Stream
The first method is to install the noncompiled nvidia drivers, this requires EPEL, DKMS, GCC, Kernel-DEVEL and Kernel-Headers dependencies to be installed. This is the most commonly used installation method, but users may find installing precompiled version would suite you better in the next section.
Install Dependencies
First, 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
Install EPEL/EPEL Next Repository (Required)
Now install EPEL repository, and the recommendation is to install both repositories. Ensure you installed the correct EPEL to the version of CentOS you are using.
Import EPEL for CentOS 9 Stream
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
Import EPEL for CentOS 8 Stream
Next, install EPEL using the following (dnf) terminal 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
Enable the PowerTools repository.
sudo dnf config-manager --set-enabled powertools
Install Nvidia Drivers proprietary or opensource drivers
Now, install the latest NVIDIA drivers.
sudo dnf module install nvidia-driver:latest-dkms
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
Alternatively, you can open the NVIDIA settings GUI from your application icon menu or use the following command.
nvidia-settings
As mentioned above, at the time of the tutorial, NVIDIA 520 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/centos/grub.cfg
Then reboot your system.
reboot