How To Make Nvidia GPU Primary in Hybrid Graphics Laptop on CentOS, RHEL7,8

The objective of this guide is to install Nvidia driver, and enable Nvidia GPU in hybrid graphics laptop all the time and use it for each and every single activity. Please do not perform these steps if you want to render your desktop using the integrated GPU and specifically select applications to be rendered using the Nvidia GPU.

Pros
  • The use of Nvidia GPU all the time would allow for smoother transitions and richer animation effects. Premium desktop environments like GNOME would benefit a lot from this.
  • Enabling the Nvidia GPU all the time would lead to lower CPU load and memory consumption which otherwise would have been high due to added in-memory video buffer.

Cons
  • With the Nvidia GPU used all the time, there would be a slight increase in battery consumption which should not be a concern if your device is used while being plugged in.
  • Increased generation of heat from the all-the-time enabled Nvidia GPU can be worrisome. You would not want to play AAA-titles on Proton while placing your laptop on your lap.
 
For the sake of this guide, we have a laptop with dual graphics adapter installed, one is intel integrated GPU and other is Nvidia GTX 950M, and we have installed CentOS Linux on top of it, as you can see in screenshot below:
 

This guide requires "Secure Boot" to be turned off from BIOS of your system (if exist) or Nvidia driver loading will fail.
 
 

Add RPMFusion Repository

First, you need to add the RPMFusion repository in your system to make the Nvidia driver packages available. To enable access to these repository, execute the following command, depending on what distribution you use and then follow the default options to install.
 
For CentOS, RHEL 7:
sudo yum -y install epel-release
sudo yum -y install https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
sudo yum -y install https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
For CentOS, RHEL 8:
sudo dnf -y install epel-release
sudo dnf -y install https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
sudo dnf -y install https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
RHEL 8 requires an additional step:
sudo subscription-manager repos --enable "codeready-builder-for-rhel-8-$(uname -m)-rpms"
CentOS Steam 8 requires an additional step:
sudo dnf config-manager --enable powertools 
CentOS 8 (older version) used a case sensitive name for the PowerTools repository:
sudo dnf config-manager --enable PowerTools
 

Install NVIDIA Driver

Type below command to install latest available Nvidia driver on CentOS, RHEL 7
sudo yum -y install gcc kernel-headers kernel-devel akmod-nvidia xorg-x11-drv-nvidia xorg-x11-drv-nvidia-libs xorg-x11-drv-nvidia-libs.i686 akmods
For CentOS, RHEL 8:
sudo dnf -y install gcc kernel-headers kernel-devel akmod-nvidia xorg-x11-drv-nvidia xorg-x11-drv-nvidia-libs xorg-x11-drv-nvidia-libs.i686 akmods
You must wait 5-10 minutes for the kernel modules to load. Please do not proceed to the next steps immediately. 
 
Execute following command to force the configuration to be read from the updated kernel modules which now have the latest Nvidia driver in them.
sudo akmods --force
sudo dracut --force
Wait for 3-5 minutes for the changes to take effect and then reboot your system.
sudo shutdown -r now 
Once your system has started, you need to locate Nvidia driver configuration file that contain display render details for the X11. Most likely, the file name would be nvidia.conf, or nvidiasomething.conf should exist under /usr/share/X11/xorg.conf.d/ directory.
ls -ltr /usr/share/X11/xorg.conf.d/
Copy /usr/share/X11/xorg.conf.d/nvidia.conf file to /etc/X11/xorg.conf.d/ with below command:
sudo cp -p /usr/share/X11/xorg.conf.d/nvidia.conf /etc/X11/xorg.conf.d/nvidia.conf
Reboot your system to activate changes.
sudo shutdown -r now 
At this stage, your Nvidia driver installation is now successfully completed. 
 
 

How to make NVIDIA GPU Primary

To make sure which GPU is currently acting as primary, open up Settings application, navigate to Details > About screen:
 

As you can see, the primary GPU in our case is intel integrated. To make Nvidia GPU primary, you need to edit nvidia.conf file like below:
sudo vi /etc/X11/xorg.conf.d/nvidia.conf
add Option "PrimaryGPU" "yes" to every Section of it:
Section "OutputClass"
Identifier "nvidia"
MatchDriver "nvidia-drm"
Driver "nvidia"
Option "PrimaryGPU" "yes"
EndSection
Save and close the editor when you are finished.
 
Your nvidia.conf file after modification, will look similar to like below:
 

 
Reboot your system to make the changes to take effect.
sudo shutdown -r now
 

Verify Nvidia Configuration

Once your system has started, go to the About page in the Settings application. You are likely to see the following output.

NVIDIA driver CentOS 7
 
As you can see, Nvidia is now primary GPU, and it will be used for each and every single activity all the time.
 
Execute below command to test your Nvidia rendering:
glxinfo | egrep "OpenGL vendor|OpenGL renderer"
It should show your Nvidia GPU like below.

 
 
Type below command to clone famous screenfetch script from github:
cd ~
git clone https://github.com/KittyKatt/screenFetch.git
cd screenFetch/
chmod +x screenfetch-dev
sudo cp screenfetch-dev /usr/bin/screenfetch
Execute screenfetch:
sudo screenfetch
It should show your Nvidia GPU under the GPU name like below:
 
 
Execute below command to open NVIDIA X Server Settings application:
nvidia-settings

You can make other configuration changes using NVIDIA X Server Settings application. Also the GPU would show activity in its utilization percentage to signify that it is actually working.


Wrapping up

In this guide you learn, how to install Nvidia driver on a dual graphics or hybrid graphics laptop running CentOS, RHEL or Oracle Linux on top of it. You also learn how to make your Nvidia GPU primary for each and every activity all the time.

No comments:

Comments with links will not be published.

Powered by Blogger.