Nvidia Optimus and Fedora 25

Hi everyone,

this is a quick howto on installing Nvidia Drivers on a Laptop with Optimus and Fedora 25. The setup is far from being perfect but at least allows me to use the Nvidia card on Fedora.
I’m using Fedora 25 MATE, i guess the setup process would be really similar for other Desktop Environments, I’d suggest you to watch the links i put as reference to get further infos.

Here are the guides i’ve been following:

 

The starting point is a clean install of Fedora 25. First of all let’s make sure everything is up to date.

dnf update

Reboot the computer so it will be running on the latest kernel.
We need also to download the latest binary driver for the nvidia card from: http://www.nvidia.com/Download/Find.aspx?lang=en-us (At the moment the latest available one for my video card is 375.26)

Next step is to install all the dependencies to allow the Nvidia driver install.

dnf install kernel-devel kernel-headers gcc dkms acpid

Then we need to blacklist the nouveau driver.

echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf

Then we need to modify the file /etc/default/grub (be careful, in the first linked guide it points to a wrong file). We’re gonna change the line:

GRUB_CMDLINE_LINUX="rhgb quiet"

in:

GRUB_CMDLINE_LINUX="nouveau.modeset=0 rd.driver.blacklist=nouveau rhgb quiet"

And then run:

grub2-mkconfig -o /boot/grub2/grub.cfg

Now we can reboot the machine and check that nouveau drivers have been properly blacklisted.
If you run:

lsmod | egrep "nouveau"

The output should be empty.
Now it’s time to install the nvidia drivers. I’m pretty sure there’s some better way to do that but from a terminal i turn off the x server running:

init 3

And then i move to the directory where i installed the nvidia drivers and run the nvidia install.

chmod +x NVIDIA-Linux-x86_64-375.26.run
./NVIDIA-Linux-x86_64-375.26.run

I followed all the default answers for the installer. After a reboot running:

lsmod | egrep "i915|nvidia"

we should notice the nvidia and intel modules being loaded. We’re almost done.
Now we have to create our xorg.conf file. Create the /etc/X11/xorg.conf.d/nvidia-optimus.conf file and paste in the following code.

Section "Module"
    Load        "modesetting"
EndSection

Section "Device"
    Identifier  "nvidia"
    Driver    "nvidia"
    BusID    "PCI:1:0:0"
    Option    "AllowEmptyInitialConfiguration"
    Option    "ConnectToAcpid"                    "0"
EndSection

Note that you should double check the PCI address for the cards even if this seems to be pretty standard. You can double check the proper PCI address running:

lspci |grep -E "VGA|3D"

# output
# 00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
# 01:00.0 3D controller: NVIDIA Corporation GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M] (rev a1)

As you can see the 2nd PCI address match the address i’ve put on the xorg.conf.

The last thing we need to take care about is to tell lightdm to turn on the nvidia card using the xrandr command.
To do that we’re going to create a bash script in /etc/lightdm called nvidia-optimus.sh, after creating the file paste in the follwoing code:

xrandr --setprovideroutputsource 'modesetting' 'NVIDIA-0'
xrandr --auto

And make it executable with:

sudo chmod +x /etc/lightdm/nvidia-optimus.sh

then we need to create the /etc/lightdm/lightdm.conf.d/nvidia-optimus.conf and paste  the lines:

[Seat:*]
greeter-setup-script=/etc/lightdm/nvidia-optimus.sh

Note: previously i used the display-setup-script but i had problems when logging out and in. Using the greeter one seems to do the trick
After a reboot you should be able to use your nvidia drivers!

Leave a Reply