How to install Nvidia drivers on CentOS 7 1810

H

Even though CentOS is not a popular OS perfectly suitable for a desktop environment, at least not for the majority of people, it is still used in combination with Nvidia GPU for video editing, visualization, artificial intelligence, and cryptocurrency mining. If you intend on using CentOS as a desktop workstation, we recommend Fedora as a suitable and more flexible OS.

Before we start the procedure, we need to update our CentOS 7 1810 desktop to the latest version:

sudo yum update
sudo yum upgrade

By using the latest version of the Linux kernel but also have a list of the latest software on the CentOS 7 repositories, you ensure that you have the latest Nvidia driver available for you but also the dependencies needed.

In order to find out the required information in regards to your Nvidia GPU on CentOS 7 you need to input one of the following commands:

lspci | grep -i --color 'vga\|3d\|2d'
sudo lshw -class display

From the output you receive, we can clearly see that we have an Nvidia GTX 1070 GPU installed on the computer.

Download the latest version of the Nvidia driver from the nvidia.com website, by selecting the product type, the series, the product itself, and the operating system. In our case, that would be Geforce, GeForce 10 Series, GeForce GTX 1070 and Linux 64-bit. You can either download through the use of a web browser or using the CLI utility wget.

wget http://us.download.nvidia.com/XFree86/Linux-x86_64/430.40/NVIDIA-Linux-x86_64-430.40.run

Installing prerequisites and dependencies

Before installing the driver, we need to ensure that we have kernel-devel and gcc kernel installed on our system:

sudo yum group install "Development Tools"
sudo yum install kernel-devel

Afterward, we need to install dkms in order to register the Nvidia Kernel module with DKMS, short for Dynamic Kernel Module support, a framework that enables generating Linux kernel modules whose sources are located outside the kernel source tree.

sudo yum -y install epel-release
sudo yum -y install dkms

In order for the Nvidia driver to work properly, we need to disable the nouveau driver that is usually installed by default for all generic video cards. For this operation, we need to to edit the file /etc/default/grub and add the following to the GRUB_CMDLINE_LINUX line:

modprobe.blacklist=nouveau

After we save the file, we need to rebuild the grub config. Depending on whether you use BIOS or UEFI, we need to input the following command:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

After the last step, the system must be rebooted.

sudo reboot

Installing the Nvidia driver

Before proceeding further, the system must be switched from graphical interface mode to console mode, otherwise, the driver will fail to install. In the terminal, input the following command:

sudo systemctl isolate multi-user.target

Log in, navigate to the folder where the driver file was downloaded and issue the following command:

sudo bash NVIDIA-Linux-x86_64-430.40.run

After the installation is complete we need to reboot the system.

Once we login back into graphical mode, we can verify if the driver has been installed correctly by checking the nvidia-settings app that is present on the desktop. We can also do this into a terminal through the usage of the following command:

nvidia-smi

This will show us the details of our GPU board, such as the driver version, CUDA version, the name of the GPU, power usage, memory usage and so much more.

Recent Posts

Archives

Categories