NVIDIA Optimus on Linux – ThinkPad W520 & Bumblebee

After my ThinkPad T400 bit the dust, it was time to upgrade/replace. As I have been doing more CAD work, and have been tempted to play with Blender, when I saw a ThinkPad W520 with integrated Nvidia Quadro 1000M for a good price, how could I resist.

However, this was not the smooth ride I was expecting.

TLDR: JUST INSTALL BUMBLEBEE AND LEGACY DRIVERS

Tales of woe below..

NVIDIA Optimus is an interesting piece of technology on laptops, whereby the graphics are run from the integrated Intel chip, with the discrete graphics card kicking in when required. Great for helping to manage battery life, whilst still having more grunt than the average laptop. On Windows, I hear this works quite smoothly, but the Linux implementations leave something to be desired – namely that it has to be called when starting a program instead of kicking in automagically. Either way, I enabled Optimus in my BIOS and started investigating.

After reading the Debian wiki, I saw that I could use PRIME offloading with the nouveau drivers, just by setting “DRI_PRIME=1” before the command. This had several drawbacks…

  • I had no control over the backlight with the nouveau drivers, so screen was full brightness at all times
  • Performance was terrible – supertuxkart ran noticeably worse with the discrete graphics!

While I do prefer open source where possible, I am not a die-hard purist, so I thought installing the official NVIDIA drivers would solve my problems. And it would be similarily easy to use, just setting some environment variables before launching the desired program.  So I installed “nvidia-legacy-390xx-driver” through apt. (If you are unsure what version of the nvidia driver to install, either check this handy list, install “nvidia-detect”)

This also had its own pros and cons – I now had control over my backlight, but it completely broke OpenGL support. Nothing would start if it required OpenGL, I just got the error:-

Xlib: extension "GLX" missing on display ":0".

This was obviously a total non-starter, so I investigated how to fix this but found nothing particularly helpful. Well, nothing that worked for me – most posts were from circa 2015 and the software stack has changed enough since then that their fixes didn’t work. So back to nouveau whilst I looked further.

Finally, I saw Bumblebee. This is a series of applications intended to manage the Optimus setup, and control power to the card etc. Following the Debian Wiki

sudo apt install bumblebee-nvidia primus

This also failed miserably during installation, as by standard it tries to install the nvidia-current drivers, which no longer support my old card. One simple change, was to install  the previously found legacy drivers at the same time.

sudo apt install bumblebee-nvidia primus nvidia-legacy-390xx-driver

This has worked like a charm! To use Bumblebee, all you need to do is run append optirun to the command, ie “optirun supertuxkart”, and the discrete graphics will render that application, passing it back to the Intel card to actually paint on the screen.

My backlight control was working again, supertuxkart looked beatiful, and I wasn’t wasting battery when I dind’t need to!

I wrote the below little script to quickly find out if the card is powered up, in case I am seeing battery drain I can see if that is a cause (or just to check it is functioning as expected)

#!/bin/bash
# Display current power state of graphics cards
# (using Bumblebee & bbswitch)

STATUS=$(cat /proc/acpi/bbswitch | grep -o -E "ON|OFF")
echo GRAPHICS CARD IS CURRENTLY POWERED $STATUS

Aside from my trips to the Debian Wiki, I did a lot of searching about the GLX issues with the Nvidia drivers, and the backlight issues with the nouveau driver.

Hopefully this post will save someone else some time if the are facing similar issues.

Picture is an edit of “bumble bee (also a jigsaw puzzle )” by uhuru1701,  and a photo of my new laptop

Leave a Reply

Your email address will not be published. Required fields are marked *