[Optimus] Setting the NVIDIA GPU as primary (RPMFusion in Fedora 32 Workstation)

Just made it into Fedora 32 the day before yesterday and I found it to be just as good as people say it is. I own a laptop with Dual GPUs so obviously setting up Optimus correctly was a bit of an issue until I followed this guide by the word and it worked just great.

Now I have

The graphics are being detected correctly. I also followed this guide, especially the part where it talks about NVIDIA Prime and the configuration did not work the way it should have. I wanted the entire desktop session to be rendered using NVIDIA GPU but it puts it to use only when I explicitly ask it to. The GNOME ends up looking ugly and feeling jittery slow due to the abysmal performance of the Intel UHD630 graphics.

Can anyone please walk me through the steps of how I can enable the NVIDIA GPU as the primary renderer for everything that gets displayed on the screen?

P.S. I do not have an option to disable the integrated graphics in the BIOS menu.

3 Likes

I figured out the solution for this by myself so I though I would write it down for my own reference and for those who are facing the same issue. The instructions are available albeit in a somehow unclear manner so I will try my best to explain stuff as lucidly as possible and add references to other places if I am not able to explain correctly.

The objective is to enable NVIDIA GPU of an Optimus laptop all the time and use it for every single activity. If you are not planning on using NVIDIA GPU for rendering everything, you might want to stop reading this solution right now. You would be much better off reading the original article at RPMFusion’s NVIDIA How-to guide.

As GNOME is one hell of a demanding desktop environment, it is no-brainer to use the discrete GPU for rendering the desktop and everything else. People may this feature call it NVIDIA PRIME or a Bumbleebee derivative but to be honest, I did only few configurations and it worked fantastically after that.

Step #1
Run sudo dnf update once to update all your packages first.

Step #2
Then you need to add the RPM Fusion repository for NVIDIA drivers. To do that, open up GNOME Software and click on the hamburger menu (three horizontal lines) on the top-right corner. Then click on Software Repositories from the dropdown menu. There you will see this.

Select RPM Fusion for Fedora 32 - Nonfree - NVIDIA Driver and ENABLE it. It requires elevated privileges so enter your password and it will be done.

Step 3
Run sudo dnf update --refresh to list all available packages from the newly added repository of yours.

Step 4
Run sudo dnf install gcc kernel-headers kernel-devel akmod-nvidia xorg-x11-drv-nvidia xorg-x11-drv-nvidia-libs xorg-x11-drv-nvidia-libs.i686 to get the drivers from the RPM Fusion repository. This command will also end up installing its dependencies from both 32-bit and 64-bit architecture, taking upto almost 200-300MB of data download.

Note that your terminal output for the above command would look significantly different from that of what I have posted here. It is not showing anything because I have already installed it on my PC.

1 Like

Step 5
Now that the drivers are all installed, you need to do one most important thing that would decide if your installation would work or not. You need to wait for some 5-10 minutes for the kernel modules to load up NVIDIA drivers. Moving on the next commands without waiting might lead to you facing the infamous black screen issue on login screen.

Step 6
After the wait, execute sudo akmods --force and sudo dracut --force in succession. This would force the configuration to be read from the updated kernel modules which now have the NVIDIA drivers in them. Also, now is the best time to turn off secure boot if you are using a UEFI system for it would not allow loading up of the updated kernel module.

Step 7
Wait for 3-5 minutes for the changes to take effect and then execute sudo systemctl reboot to reboot your system. Once your system has started, go to the about page in the Settings application. You are likely to see the following output.
Screenshot from 2020-04-28 08-28-19

This effectively means that the driver installation was successful. Leading to the detection of two distinct video accelerators - internal and discrete. If you wanted to use the internal GPU for basic rendering - that is to render the desktop environment and stuff and use the discrete GPU for specific applications, you can stop here.

But if you wish to entirely use your discrete GPU for both desktop environment and applications - read on the next steps and keep on implementing them as you go.

1 Like

Step 8
Now, in order to make all the rendering default to the discrete GPU, you need the follow the next steps very carefully. But first, you need to see if you really want to achieve this.

Why should you do that?

  1. Desktop environments as premium as GNOME, KDE and Deepin cannot afford to have the slightest of jitters. Your experience would be compromised if the animations are not smooth.
  2. You are likely to have greater memory consumption as a part of the RAM would be used to store the video buffer. CPU load will also increase to handle the video processing tasks.

Why should you not do that?

  1. With the discrete GPU turned on and used all the time, the battery life is likely to go haywire here. It should not be a concern for those who constantly use their devices while plugged.
  2. Increased generation of heat from the discrete GPU can be worrisome. You cannot quite play AAA-titles on Proton while keeping your laptop on your lap if you don’t want to get burnt.

Step 9
Execute the following command to copy the render details for the X11. cp -p /usr/share/X11/xorg.conf.d/nvidia.conf /etc/X11/xorg.conf.d/nvidia.conf

Once done, open up the nvidia.conf from the copy destination and edit it to add Option "PrimaryGPU" "yes" to every section of it.

Open it using sudo nano /etc/X11/xorg.conf.d/nvidia.conf and make changes.

The file should look like this. Do not panic if it looks sightly different.

Look closely. I have added that line in both the sections.

Save it using [Ctrl]+[S] and exit out using [Ctrl]+[X].

Step 10
Reboot your system. We will run some tests in the next steps to see if it really worked or not.

2 Likes

Step 11
Open up a terminal and type glxinfo|egrep "OpenGL vendor|OpenGL renderer" - If every configuration was done right, it should show up your discrete GPU and not the internal one.

Check on screenfetch - It should show your discrete GPU under the GPU name.

Check in your Settings application. You would see something like this in the about page.

You would see a lot to tinker in your NVIDIA X Server Settings application. Also the GPU would show activity in its utilization percentage to signify that it is actually working.

Step 12
If you were able to follow the instructions and come this far, you deserve a pat on your back. To be honest, a lot of my friends opt for Debian-based and Ubuntu-based distributions like Pop!_OS to ease the pain of installing NVIDIA drivers by themselves. Fedora is pure love and it is heart-breaking to see how limited documentation is available in this regard. As a consequence of minimal documentation and the futile pursuit of elitism, the community loses people to distributions which are much more friendlier to these aspects.

5 Likes

References
This thread would go inert due to inactivity so even if I would more than love to answer questions and queries - I would not be able to. I am attaching the reference material so that if my steps do not work out for you - maybe theirs will. But feel free to PM me in case of doubts.

  1. Howto/Optimus - RPM Fusion
  2. Howto/NVIDIA - RPM Fusion
  3. hardware - How to check which GPU is active in Linux? - Unix & Linux Stack Exchange
  4. https://www.reddit.com/r/Fedora/comments/bw4b0p/how_to_fedora_nvidia_prime/ (zvitaly’s response only)

And please for the love of everything holy
Stay away from this site - Fedora 37/36/35 NVIDIA Drivers Install Guide [525.85.05 / 520.56.06 / 515.86.01 / 510.108.03 / 470.161.03 / 390.157 / 340.108] – If Not True Then False

3 Likes

@t0xic0der Great guide - I assume this will be helpful to many other users
@FranciscoD Should we transform this thread into a Wiki page?

2 Likes

A quick doc perhaps? :smiley:

3 Likes

I would say: plus one

@t0xic0der, are you part of the docs team already? Would you be interested in contributing?

2 Likes

Hello,
First, thanks for the guide and effords you have done.
I’m coming crazy with Optimus configuration on Fedora and others distro.
I use a msi laptop (i7 9750+IntelUHD630+GTX1660ti) and the only case i met that a distro work at install from scratch using PRIME Nvidia card (for performance preference) is pop_os in multi monitor configuration.

But i want really to use Fedora because is for me a perfect mix between new features coming and solid linux background with corp needs.

My point is that i would like to know if you have tested multi monitors configurations ?
My big problem is always only one monitor work in any nvidia prime configurations i have been testing.

I did not find on web the exact way to determine the configuration mux between intel and nvidia cards and the connectors dependancies, if you have a link?!

I have seen your configuration is made of GTX 1050 nvidia card(for notebook), looking at nvidia site for my card (1660ti Notebook), the last driver available is 435.21, dependencied with kernel 5.3 !
So i’m done :sweat: :sweat: :sweat:

I tried since one week with Fedora 32 beta, the install with Nvidia drivers and the multimonitor did not work, but i did not add PRIME gpu nvidia setting and i did not wait minutes for module kernel loads.

I think this situation for many linux users of laptop as me is really a big fear. I like linux philosophy but i’m exigent about performance gui and i want to pass 99% time in linux and not M$ anymore.

I will try again following your guide.
Thanks again.
(sorry for my not perfect english)

1 Like

Hi @dahikino, welcome to the Fedora community! Please do not worry about language, we’re a global community and English is not the first language for most of us :slight_smile:

If you’ve not had a chance yet, please look at the #start-here category. It has some very useful information on using the forum and tips on Fedora usage.

If you do run into errors, please open a fresh topic and folks will try to help you there.

Just a question, does downgrade Kernel is really risky for Fedora 32 in general?
My next test is Fedora 32 kernel 5.3 and akmod nvidia 390xx from rpmfusion source.

You’re welcome @florian. I would be glad if this thread is turned into a wiki page :innocent:

No @florian, I am not a part of the docs team but I would be willing to contribute. :grin:

Hi @dahikino,

The Step 9 discusses about settings a PrimaryGPU parameter to the nvidia.conf file. If you go to the RPMFusion How-to guide in Optimus and read the NVIDIA PrimaryGPU Support section, you would see that the same lines that I told about also ends up enabling the external display support. This effectively means you can select from the discrete GPU or integrated GPU to render either your plugged in display or the internal display.

I would never recommend getting drivers from the NVIDIA’s official website. The RUN file that they provide is generic for all distribution and might end up replacing and modifying multiple files in an untrackable way. Using their installer might just mess up your system pretty bad - and no, kernel 5.3 is definitely not the requirement for the GPU driver. I am running the configuration I specified about in the latest kernel 5.6.7 and things are as smooth as Amul butter.

Waiting those minutes after installation is one of the most crucial steps. You need to give some time before the kernel loads up the NVIDIA driver on itself or you might face the black screen issue on boot - That happens because the GRUB was configured to expect NVIDIA driver on the kernel but does not get it for it was not allowed to build in the first place. Adding the PrimaryGPU configuration is more of a preference thing, it just makes your discrete GPU as the primary renderer.

Please follow my guide to word and you would see pleasing results. :innocent:

Downgrading your kernel to 5.3 is not at all risky but it is not recommended. Newer kernels are likely to have better updates, patches for loopholes and fixes for issues so you are much better off with having the latest kernel. Also, why are you opting for an ancient 390xx driver for a discrete card as new as 1660Ti?

Thanks a lot for your answer, i will give obviously a try having done a backup first via Timeshift !

Well, i admit that to know which number version i can use, is confusing me because looking nvidia driver web site, it purpose only a 435.21 for laptop version.
Rpmfusion purpose only 390xx or 440.82 (but this last it is not for laptop version following nvidia recommendation, it is only desktop version of the 1660ti).

I have been lost by this.