Search This Blog

Thursday, July 28, 2016

Bumblebee on Ubuntu 16.04! Revised !

Bumblebee on Ubuntu 16.04! Revised !

Well life is not very easy, is it? I have been puling my hair out for the past 2-3 months when all of a sudden my bumblebee setup on Ubuntu 16.04 started to freak out. I have been monitoring my blog for comments and all my readers say they have had either a login loop or they have had black screens after following my instructions. Many have had weird issues with primus not connecting to bumblebee daemon.

So i have been searching the good old INTERNET while using nvidia-prime myself as an alternative and always asking my readers to not use driver other than nvidia-367. Well all was good for some time and then all of a sudden one day I started having the worst possible screen tearing with nvidia-prime and I was again disappointed with the state of primus support on Linux.

Have been trying various distributions to find out switching distros would really help. So I switched to all other possible distros. So what now?

I was very pissed wth all this and I had been talking to a friend of mine by the name Brett Stevens. We together cracked this puzzle.

So what exactly is the issue with this whole login loop (I thought switching to another Display Manager would help, Alas ! That changes nothing ) and black screen after bumblebee installation.

So how did I fix it?

“Here is how. By Installing Bumblebee and Nvidia-Prime both.” Now you would say that is crazy, How can that even work? Yeah Yeah ! I hear you. Please keep reading and you will have your answers.

So something changed with an update to Nvidia-36X.XX Series of drivers in Ubuntu 16.04 sometime after my earlier bumblebee post. Not sure what it was but here is the behaviour.

Something has been causing nvidia_drm, nvidia_modeset and nvidia-uvm to automatically load at boot. Nothing could prevent these bad boys to stop loading at boot. These automatically loading at boot is the reason why you have the login loop and black screen. So what to do . I tried manually blacklisting the modules but they would not stop. This was because nvidia drivers were enabling modesetting and automatically activating.

So we need something to prevent these modules from automatically loading. We now had a clear problem statement with no solution. So what to do. And then Brett Came across this article.

This changed the whole direction of investigation. I could not help noticing this step in his article.

sudo prime-select intel  

This was something I could not digest. However looking deeper we found that this was real. We were able to force the system to always use Intel using prime-select. The package nvidia-prime works a bit differently than bumblebee, It completely disables nvidia-card and forces intel card to be primary all the time. It can also force the system to use nvidia card as well.

Once Intel is forcefully made primary, There are no more login loops no more black screens. Now In addition to this we installed bumblebee as usual. No more errors, Switching is perfect. No issues.

So without further delay. Here are the simplified instructions.

To install and Configure Bumblebee on Ubuntu 16.04, Open up a Terminal and

Run the following Commands in Sequence

1) sudo apt-get update && sudo apt-get upgrade

2) sudo apt-get dist-upgrade

3) sudo apt-add-repository ppa:graphics-drivers/ppa (Skip this step if you are no t going to use Nvidia-364 or higher in future.)

4) sudo apt-get update && sudo apt-get dist-upgrade

5) sudo apt install nvidia-prime nvidia-367

6) sudo prime-select intel

7) sudo apt-get install bumblebee bumblebee-nvidia primus nvidia-settings nvidia-367 (You could use nvidia-364 or nvidia-367 if you have enabled Graphics Drivers PPA )

Once this is Installed, Below files need to be edited as shown.

1) sudo gedit /etc/modules



2) sudo gedit /etc/modprobe.d/bumblebee.conf

Check for this

# 361
blacklist nvidia-367
blacklist nvidia-367-updates
blacklist nvidia-experimental-361

Ensure that this section shown above exists. If not add it manually.

3) sudo gedit /etc/bumblebee/bumblebee.conf




(Or whatever version of Driver is latest if using Graphics Drivers PPA)

Also Change

Driver = nvidia on Line Number 22

7) sudo gpasswd -a $USER bumblebee

8) sudo systemctl enable bumblebeed

9) Reboot

10) Install mesa utils if not already installed

sudo apt-get install mesa-utils

Check using

11) primusrun glxinfo | grep OpenGL

You shoud see a result like this.

OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce 820M/PCIe/SSE2
OpenGL core profile version string: 4.5.0 NVIDIA 367.35
OpenGL core profile shading language version string: 4.50 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.5.0 NVIDIA 367.35
OpenGL shading language version string: 4.50 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:

This means all is well and  your bumblebee setup is working.

If you would like to see if bumblebee is actually working, try this

lsmod | grep bbswitch

You should see something similar to this

bbswitch 16384 0

The number in second column is Random and will vary.


if you run.

cat /proc/acpi/bbswitch

You should see something like this

0000:03:00.0 OFF

This means that your Nvidia Card is OFF by default. Once you run an application using primusrun or optirun commands, while the program you run is running you can see that the OFF change to ON Like below.

primusrun glxgears

this runs the glxgears program using your Nvidia Card via bumblebee.

Open another terminal and run.

cat /proc/acpi/bbswitch

You should see something like

0000:03:00.0 ON

Now Close the application which you launched via bumblebee earlier, in this Case glxgears.

again run

cat /proc/acpi/bbswitch

You should see something like this.

0000:03:00.0 OFF

If all is going like I have mentioned then you can be sure that bumblebee is configured correctly.