[GUIDE] How to properly install Nvidia Non-Bumblebee drivers on Optimus Laptops

Here is where you can post tips and tricks to share with other users of MX. Do not ask for help in this Forum.
Message
Author
SenôrBruno

[GUIDE] How to properly install Nvidia Non-Bumblebee drivers on Optimus Laptops

#1 Post by SenôrBruno »

Good evening everyone.
First of all I would like to say that by no means I am any expert of MX. I've already had tried a few times to install the nvidia drivers without bumblebee in the past to no avail, which always made me walk away from this distro. Last night I decided to give it another try on one my laptops, and after a few hours of back-and-forth tinkering I finally did it. So in hope to ease this process to others wanting to do the same, I decided to write this guide. If any of the admins or mods feel this is not the appropriate place to put it , feel free to move the topic elsewhere, as well as correct anything you deem necessary.
But first, a small explanation:

Why not use Bumblebee?

Bumblebee, as stated in https://github.com/Bumblebee-Project/Bumblebee/wiki/FAQ, is an "effort to make Nvidia Optimus enabled laptops work in GNU/Linux systems. Such feature involves two graphics cards with two different power consumption profiles plugged in a layered way sharing a single framebuffer." In simple words, it 'mimics' the behaviour you see in Optimus Laptops with Windows, where you have the integrated GPU doing the work most of the time, but when more intensive applications such as games or video editors are started, it 'switches' to the dedicated GPU to do the heavy work. This is done to save power, as dedicated GPUs are hungry bois and will decrease your battery life significantly.

AFAIK, the only way the MX team officially provides non-free drivers is with Bumblebee. However, IME the nvidia's driver performance with Bumblebee is...mediocre. And I'm being soft. Giving an example, with the NVidia drivers only I am able to run CS:GO at 60 fps +/- stable with low settings, whereas with the Bumblebee it is hard to pass over 25 fps. And sometimes, on certain hardware, installing Bumblebee itself can reveal to be very tricky. It's developers have the best intentions I'm sure, but with no access to the drivers source code being closed (I think? Nvidia likes to be nasty) it is definitely a challenge.

And sometimes, users (such as myself) prefer to have a better performance than better power saving, simply because power consumption is not a problem. You can take a look at the table that shows at the begining of https://forum.manjaro.org/t/howto-set-u ... iver/40225 to understand better the options you may follow. However, you must be warned : although it's getting better, Nvidia support for Optimus is still very, very messy. The following guide may not work in all hardware configurations.

In my case I used an ASUS X555LD (Intel i3 quad-core at 1,60 Ghz with iGPU , 4 GB Ram and an 2G Nvidia 820m dGPU) to install the drivers. Kernel is 4.19.0.6-amd64.
I will also assume that you the user have a minimal knowledge of terminal and system usage.

Important Note: There are some Optimus laptops with a setting in the BIOS which allows you to disable the integrated GPU. Before following this guide, you should check your laptop BIOS for that option, because if you do have it and enable it, the laptop will not be recognized as an Optimus one. This way you can install the nvidia drivers without bumblebee through the MX Nvidia Installer, and you don't need to follow this tutorial. If you don't have that option in your BIOS, feel free to continue reading. I'd like to thank to @Stevo for reminding me this.

1. Detect the nvidia driver you need for your card
Fortunately some folks have made a binary called nvidia-detect which makes this part very easy. Just run it in the terminal ( use apt-get to get it if you don't have it) and it will display the name of the non-free driver you are after. In my case it showed me this:

Code: Select all

Your card is on supported up to the 390 legacy drivers series
It is recommended to install the
	nvidia-legacy-390xx-driver
package.
I have an old card so I have to use the legacy driver. However for newer cards you should see the newer drivers being recommended (as of now the newest was 440 something, although Debain seems to have only up to 430), and the steps in this guide serves both.

2. Installing the nvidia driver and required packages
So now that you know the driver you need to install let's take a look at the other packages that are recommended to install.

https://packages.debian.org/sid/nvidia- ... 0xx-driver
https://packages.debian.org/sid/nvidia-driver (430 version)
You can do this by choosing the link that matches your driver. For full integration I advise you to install the recommended (rec) packages as well.
So in my case I did:

Code: Select all

 sudo apt-get install nvidia-legacy-390xx-driver libnvidia-legacy-390xx-cfg1 nvidia-settings-legacy-390xx nvidia-legacy-390xx-kernel-dkms nvidia-persistenced  nvidia-legacy-390xx-driver-libs-i386 libgles-nvidia-legacy-390xx1 libgles-nvidia-legacy-390xx2 nvidia-legacy-390xx-vulcan-icd 
Note: the last four packages in the command come off as recommended from the other ones, are not necessary for the driver to work and can be installed later. However, if you intend to play games through Steam or Wine you will need them so you can install them right away.

3. Configure the Nvidia persistence daemon
There may be a case where during the install , the persistence daemon may be installed first than the kernel module, and started without it(so I think): this will make it fail and you might see a message like this:

Code: Select all

nvidia-persistenced failed to initialize. Check syslog for more details.
If you spotted this message during the install, run:

Code: Select all

sudo dpkg --configure nvidia-persistenced
The daemon should activate and create a symlink. If you are not sure if the error happened you can run the command anyway, as it will say there is nothing be done if there are no errors.

4. Configure X.Org server
The X server needs to recognize the nvidia card before we can use it

4.1 Know the BusID of your dGPU card
To proceed to the next step you need to know what is the BusID of your dedicated GPU. You can do this by running in the terminal:

Code: Select all

lspci -nn | egrep -i "3d"
And it will output something like this:

Code: Select all

04:00.0 3D controller [0302]: NVIDIA Corporation GM108M [GeForce 920MX] [10de:134f] (rev a2)
The first 5 numbers (04:00.0) are the BusID of my card. Hold on to your numbers.

4.2 Create/Modify xorg.conf
Create a file (or modify it if you already have it) /etc/X11/xorg.conf. I'm using nano as the text editor

Code: Select all

sudo nano /etc/X11/xorg.conf
Now add these lines, but instead of having "X:Y:Z" you must insert the numbers of the BusID of your card!

Code: Select all


Section "Module"
	Load "modesetting"
EndSection

Section "Device"
	Identifier "nvidia"
	Driver "nvidia"
	BusID "PCI:X:Y:Z"
	Option "AllowEmptyInitialConfiguration"
EndSection

For my example since my number is 04:00.0 I had to write PCI:4:0:0

5. Configure Display Setup Script
The last step is basically to tell the display manager that want to use the Nvidia card. In my example I will use lightdm but the idea is always the same: the display manager needs a script to set the output source to the Nvidia card before starting. Others can find useful info at https://wiki.debian.org/NvidiaGraphicsDrivers/Optimus

5.1 Search for display setup scripts
If you examine the lightdm.conf file (in /etc/lightdm/lightdm.conf) you may discover that a display-setup-script is already assigned in the [SeatDefaults] tab. In my case I had display-setup-script=/usr/local/bin/early-bg , so in this case there is no need to create a new script; we will just add the information to this one. I honestly don't know If this is a hacky solution, but AFAIK lightdm only allows to have one script assigned to each system hook (correct me if I'm wrong please) so that'll have to do.

5.2 Create/Modify display setup script
If you did not find any script assigned, you can proceed to create one in /usr/local/bin

Code: Select all

sudo nano /usr/local/bin/nvidia.sh 
If you did find a script assigned ( in my case I found display-setup-script=/usr/local/bin/early-bg ) then you will have to modify that one.

Code: Select all

sudo nano /usr/local/bin/early-bg
Add in the following lines (if it's in a found script add at the end, don't forget to leave last line as blank) and save the file:

Code: Select all


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

6. Reboot / Restart X server .
If all went well, you should be ready to reboot your system. If it reboots successfully, try to open nvidia-settings through the terminal. If it opens successfully ( you 'll see many tabs, opengl settings, info on your card , performance settings and so on) , that's it! You know have a Nvidia card running at full performance!

A. Something went wrong.
If any of the described steps didn't work for your, or if you simply wish to use another option you can always rollback to the open source drivers with sudo ddm-mx -p nvidia

B. Alternatives to Bumblebee?.
Directly? No, but there are other ways to achieve the GPU switch. One of them is PRIME, but as of the time of this writing I still didn't tried anything. If I discover how to do it I'll update this guide.

One last thing, if you eventually are able to follow these steps sucessfully at the end, you can be a friend and state on what hardware did you achieved it...that way more and more people will get a definite yes instead of a maybe :)

Cheers.

EDIT 1 It seems that in my pc the plymouth service would fail after following this guide. If someone comes across the same error, please comment down below. In any way, since I like to see the whole boot process I removed plymouth. Using kernel parameter "nosplash" also does the trick. System now runs smoothly, and I've tried some games with sucess!
Last edited by SenôrBruno on Wed Jan 08, 2020 9:51 pm, edited 1 time in total.

User avatar
Stevo
Developer
Posts: 14625
Joined: Fri Dec 15, 2006 7:07 pm

Re: [GUIDE] How to properly install Nvidia Non-Bumblebee drivers on Optimus Laptops

#2 Post by Stevo »

Thanks for the guide. You might want to add that some laptops allow for the Intel GPU to be disabled, in which case the MX Nvidia Installer could be used, since it wouldn't see it as an Optimus machine.

SenôrBruno

Re: [GUIDE] How to properly install Nvidia Non-Bumblebee drivers on Optimus Laptops

#3 Post by SenôrBruno »

Stevo wrote: Wed Jan 08, 2020 7:53 pm Thanks for the guide. You might want to add that some laptops allow for the Intel GPU to be disabled, in which case the MX Nvidia Installer could be used, since it wouldn't see it as an Optimus machine.
Thank you for the feedback and the reminder! I added the information at the beggining.

User avatar
andyprough
MX Packager
Posts: 918
Joined: Tue Jul 23, 2019 10:16 pm

Re: [GUIDE] How to properly install Nvidia Non-Bumblebee drivers on Optimus Laptops

#4 Post by andyprough »

This is very interesting, I'll have to try it, maybe tomorrow or the next day. I wonder if KDE Plasma will automatically use wayland as the display manager with Nvidia in a Non-Bumblebee setup? I know it does not automatically use wayland when I am running the Bumblebee setup.
Primary Computer - Commodore 64: Processor - MOS 6510/8500, 1.023MHz; Memory - 64kb RAM, 20kB ROM - 8k BASIC V2, 8k Kernel, 4k Character ROM; Display output - 320x200, 16 colours; OS - BASIC V2.0; Weight: 1.8kg

SenôrBruno

Re: [GUIDE] How to properly install Nvidia Non-Bumblebee drivers on Optimus Laptops

#5 Post by SenôrBruno »

andyprough wrote: Wed Jan 08, 2020 11:39 pm This is very interesting, I'll have to try it, maybe tomorrow or the next day. I wonder if KDE Plasma will automatically use wayland as the display manager with Nvidia in a Non-Bumblebee setup? I know it does not automatically use wayland when I am running the Bumblebee setup.
@andyprough I did a quick search this afternoon and from what I understood, the Nvidia//Wayland and KDE setup seemed very troublesome until this happened https://www.phoronix.com/scan.php?page= ... -KWin-5.16 so I'm guessing it might be better now. Maybe this was the same reason which made your system use xorg instead of wayland in your bumblebee setup. In any case if you do have success post here, along with your specs :)

sommenom
Posts: 20
Joined: Fri Mar 06, 2020 7:18 pm

Re: [GUIDE] How to properly install Nvidia Non-Bumblebee drivers on Optimus Laptops

#6 Post by sommenom »

.

SenôrBruno thank you for guide and inspiration.
Bumblebee have bug with my hardware.
Well then I tried and tested this process on MX-18.3 xfce :

1) Prepare for installation :
update and full upgrade operating system, then install new kernel with headers

Code: Select all

linux-image-4.19.0-8-amd64-unsigned
linux-headers-4.19.0-8-amd64
linux-headers-4.19.0-8-common
Reboot

2) Nvidia driver installation :
Package "nvidia-legacy-390xx-driver" not found. Never mind, via Synaptic install :
nvidia-driver (version: 390.116-1 with maybe around 20 suggesting packages)
nvidia-settings
nvidia-persistenced

3) Creation xorg.conf like has been suggested in 4. Configure X.Org server

4) Configure Display Setup Script like has been suggested in 5. Configure Display Setup Script

Turn off and turn on computer.

This works on my asus notebook :

Code: Select all

$ inxi -SMCG
System:    Host: ****** Kernel: 4.19.0-8-amd64 x86_64 bits: 64 Desktop: Xfce 4.12.3 
           Distro: MX-18.3_x64 Continuum May 26  2019 
Machine:   Type: Laptop System: ASUSTeK product: N552VW v: 1.0 serial: <root required> 
           Mobo: ASUSTeK model: N552VW v: 1.0 serial: <root required> UEFI: American Megatrends v: N552VW.304 date: 05/08/2019 
CPU:       Topology: Quad Core model: Intel Core i7-6700HQ bits: 64 type: MT MCP L2 cache: 6144 KiB 
           Speed: 900 MHz min/max: 800/3500 MHz Core speeds (MHz): 1: 900 2: 900 3: 900 4: 900 5: 900 6: 900 7: 900 8: 902 
Graphics:  Device-1: Intel HD Graphics 530 driver: i915 v: kernel 
           Device-2: NVIDIA GM107M [GeForce GTX 960M] driver: nvidia v: 390.116 
           Display: x11 server: X.Org 1.19.2 driver: modesetting,nvidia resolution: 1920x1080~60Hz 
           OpenGL: renderer: GeForce GTX 960M/PCIe/SSE2 v: 4.6.0 NVIDIA 390.116
.

User avatar
Stevo
Developer
Posts: 14625
Joined: Fri Dec 15, 2006 7:07 pm

Re: [GUIDE] How to properly install Nvidia Non-Bumblebee drivers on Optimus Laptops

#7 Post by Stevo »

The legacy 390xx drivers are in the MX 17/18 test repo, but stick with the standard ones unless you need a newer kernel like 5.something from the TR, since the Stretch ones won't build with those.

engmex
Posts: 5
Joined: Sat May 30, 2020 7:02 pm

Re: [GUIDE] How to properly install Nvidia Non-Bumblebee drivers on Optimus Laptops

#8 Post by engmex »

Thanks for this guide. I have it working on Lenova Y70-50 with a GeForce GTX 860M. I installed the Nvidia driver 440.82-1mx19+1 and it's dependencies from the MX test repository. I had an issue with screen tearing when moving windows, scrolling webpages and watching videos. This was easily fixed by opening boot options in MX tools and placing nvidia-drm.modeset=1
in the boot options section.

User avatar
Gnabbist
Posts: 2
Joined: Sun Sep 30, 2018 3:43 pm

Re: [GUIDE] How to properly install Nvidia Non-Bumblebee drivers on Optimus Laptops

#9 Post by Gnabbist »

Success, using the standard Nvidia drivers, on an Acer laptop from 2018:

Code: Select all

$ inxi -SMCG
System:    Host: A715-72G Kernel: 4.19.0-6-amd64 x86_64 bits: 64 Desktop: Xfce 4.14.2 
           Distro: MX-19.2_x64 patito feo October 21  2019 
Machine:   Type: Laptop System: Acer product: Aspire A715-72G v: V1.26 serial: <root required> 
           Mobo: CFL model: Charmeleon_CFS v: V1.26 serial: <root required> UEFI: Insyde v: 1.26 
           date: 03/27/2019 
CPU:       Topology: 6-Core model: Intel Core i7-8750H bits: 64 type: MT MCP L2 cache: 9216 KiB 
           Speed: 800 MHz min/max: 800/4100 MHz Core speeds (MHz): 1: 800 2: 800 3: 800 4: 800 
           5: 800 6: 800 7: 800 8: 800 9: 800 10: 800 11: 800 12: 800 
Graphics:  Device-1: Intel UHD Graphics 630 driver: i915 v: kernel 
           Device-2: NVIDIA GP107M [GeForce GTX 1050 Ti Mobile] driver: nvidia v: 418.113 
           Display: x11 server: X.Org 1.20.4 driver: modesetting,nvidia 
           resolution: 1920x1080~60Hz 
           OpenGL: renderer: GeForce GTX 1050 Ti/PCIe/SSE2 v: 4.6.0 NVIDIA 418.113
My two target games (Euro Truck SImulator 2 & American Truck Simulator) are running better than I've ever seen them run on this machine. Well done, and thanks!

User avatar
cer0
Posts: 14
Joined: Wed Oct 14, 2020 11:34 am

Re: [GUIDE] How to properly install Nvidia Non-Bumblebee drivers on Optimus Laptops

#10 Post by cer0 »

Hi, I follow this tutorial using MX with KDE that uses sddm as Display manager and the setup script is in /use/share/sddm/scripts/Xsetup.
I reboot after step 5 and got a black screen in tty7.
The Xorg log says

Code: Select all

(EE) No divices detected.
(EE) Fatal server error
No screens found
Any suggestions??

Post Reply

Return to “Tips & Tricks by users (not for help)”