Main menu

How To Make Nvidia Optimus Technology Work (properly) On Debian

Published by gnugr on Thu, 03/05/2015 - 17:45 in

Hello guys! My name is Cosmin Crihan and I am writing this tutorial in order to show you how to make the Nvidia optimus technology properly work on Debian systems. For Ubuntu or Linux Mint users, I am aware of a little button that triggers the usage of the Nvidia X Org Server or the Nouveau Drivers, at your command. But you all know that Debian is not simple, but powerful. Here, it is not so easy.

I wanted to write this tutorial because it took me an entire week to make my video card work on my system and I found that this problem affects many many users having the Optimus technology from Nvidia. Note that some users might still use the card no problem by activating it from the BIOS (toggling the Discrete Graphics option). Well, I don’t have this option, and many don’t.

For those who don’t know what is Nvidia Optimus, it is an Nvidia technology that should trigger the usage of your dedicated video card on demand, so it consumes less power and only activates itself if it is needed. In other words, if the PC needs video performance, the dedicated card gets into action. That’s the theory: welcome to Linux! (if you know what I mean).

First, I must mention a part of this tutorial is from this link.

DO NOT install the official drivers from the nvidia website, because they do not work, and if they do install, you will need to reinstall them at each kernel upgrade. They are a useless piece of crap, in that form there, on the driver download page.

Follow these steps carefully in order to setup your system to use the discrete card. If you already have things installed from Nvidia, purge everything:

sudo apt-get remove --purge nvidia*
1. You will need to enable the 32-bit architecture on your system, like so:

sudo dpkg --add-architecture i386
2. Update your system

sudo apt-get update
3. Install the required packages:

sudo apt-get install bbswitch-dkms intel-microcode firmware-linux-nonfree bumblebee bumblebee-nvidia primus primus-libs primus-libs:i386 linux-headers-$(uname -r)
If this command complaints about not finding some of the packages, check if you have enabled the non-free repositories in your sources.list file. Open it: “/etc/apt/sources.list” and check that you have “non-free contrib” added at each line.

Note that during installation, you will be prompted by some blue screens telling you to configure manually the Nvidia X server, and to blacklist the Nouveau conflicting driver. Ignore everything and continue the installation (it’s fine).

4. After installation, open this file as root, with your favorite text editor: /etc/bumblebee/bumblebee.conf

For example,

sudo mousepad /etc/bumblebee/bumblebee.conf
Find within the file, this line: “KernelDriver=”. It should be empty after the equal sign, or it might contain “nvidia”. Write “nvidia-current” instead, so it looks like: “KernelDriver=nvidia-current”.

5. Add your user to the bumblebee group, if not already done:

sudo addgroup bumblebee
If this says you were already added, it is OK.

6. You need to also append a new boot parameter. Use your text editor to open /etc/default/grub.

Example:

sudo mousepad /etc/default/grub
Find the line “GRUB_CMDLINE_LINUX_DEFAULT” and add the parameter: “rcutree.rcu_idle_gp_delay=1″

Example of the line in cause, after modification: GRUB_CMDLINE_LINUX_DEFAULT=”quiet rcutree.rcu_idle_gp_delay=1″

7. Update GRUB and regenerate the boot image:

sudo update-grub
8. Reboot and you are done!

You can use your discrete video card with the “primusrun” or “optirun” commands. After the restart, try it in your terminal:

optirun glxgears
You will be presented an animation with some rotating coloured gears, that is really rendered with your Nvidia card.

To open a process with your dedicated video card, simply add “primusrun” or “optirun” in front of the command.

Example:

“primusrun ./AmnesiaAMFP” (supposing I am in the “Amnesia – A Machine for Pigs” game folder).

For Steam games, you need to place a special code in the game launch options, to run it with the Nvidia video card. Right click the game you want to be opened with the discrete graphics card every time, choose “Properties”. In the new window that appeared, click “SET LAUNCH OPTIONS” and write there “primusrun %command%”. Close the properties window and you’re ready to go.

These commands are very useful, I even opened Google Chrome with primusrun to watch a Youtube 4K video, so it was rendered with my Nvidia card, as it was laggy with the Intel chip.

And now, I must mention about a recent bug, that prevents primusrun from working with some games, especially on Steam. Recently, after some updates, I noticed that games like Left4Dead 2, Antichamber, Half Life, Oil Rush, and many others stopped working with primusrun, they just don’t run at all, crash with a puzzling error (if you run them in terminal). I researched this and found out that it is a problem with a package called libdrm-intel1 that is bugged in it’s recent version, 2.4.58.

NOTE: Proceed to the next workaround step only if you need to (if the primusrun command does not start your games properly, or it does for some only). Check the version of your libdrm-intel1 package, like this:

apt-cache show libdrm-intel1 | grep Version
If it returns 2.4.58, try the workaround:

If you are experiencing the same bug (games don’t run at all), you must downgrade the package to version 2.4.56. It is a workaround until we expect a future fix. But that is not all, of course. The package depends on other 10 packages that also need downgrading, so that the package manager does not complain about dependency breaking.

The packages that need downgrading are: libdrm-dev libdrm-dev:i386 libdrm-intel1 libdrm-intel1:i386 libdrm-nouveau2 libdrm-nouveau2:i386 libdrm-radeon1 libdrm-radeon1:i386 libdrm2 libdrm2:i386

You need all these installed over the new ones, version 2.4.56.

You can either Google them, find them on the official Debian packages website, or download them from the archive I made here: http://www.filedropper.com/primusfixtar

Install everything in there with,

sudo dpkg -i *.deb
ignoring all the warnings about downgrading.

After you do this, there is another step to ensure that your package manager does not update these thing back. To prevent this happening, you can use the “apt-mark hold” command, to “hold” a package from upgrading itself.

Write this in terminal:

sudo apt-mark hold libdrm-dev libdrm-dev:i386 libdrm-intel1 libdrm-intel1:i386 libdrm-nouveau2 libdrm-nouveau2:i386 libdrm-radeon1 libdrm-radeon1:i386 libdrm2 libdrm2:i386
If you try to upgrade the system, you will be greeted with something like this:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
libdrm-dev libdrm-dev:i386 libdrm-intel1 libdrm-intel1:i386 libdrm-nouveau2
libdrm-nouveau2:i386 libdrm-radeon1 libdrm-radeon1:i386 libdrm2 libdrm2:i386
This is normal, it will not affect the upgrading process, but it will keep those packages at the required version for primusrun to work, for now.

That is all you need for now, until a fix is made for the buggy package “libdrm-intel1″. When a fix will be available, we must leave the held packages to upgrade themselves, by running:

sudo apt-mark unhold libdrm-dev libdrm-dev:i386 libdrm-intel1 libdrm-intel1:i386 libdrm-nouveau2 libdrm-nouveau2:i386 libdrm-radeon1 libdrm-radeon1:i386 libdrm2 libdrm2:i386
Done!