Search This Blog

Saturday, April 23, 2016

How to Install Latest Nvidia Drivers on Ubuntu 16.04 Xenial Xerus using Bumblebee or Nvidia-Prime

How to Install Latest Nvidia Drivers on Ubuntu 16.04 Xenial Xerus using Bumblebee or Nvidia-Prime

First of all many may thanks to all my readers for their continued support. I am truly thankful.

It has been almost more than 6 Months since the Ubuntu 15.10 release. Wily was a great release as we all know, we however have a new and much anticipated release of my favorite distribution. Yes I am talking about Ubuntu 16.04 Xenial Xerus.

The Only think which puts me off a little bit about this release is just Name but like Shakespeare said "What is in a Name!". This is so much true about Ubuntu 16.04.

There are so may new features in this release and so many things have changed that this calls for a new post. Some of the Instructions which I have used in the past may not necessarily apply to this. As far as bumblebee is concerned, There are multiple changes.

Bumblebee package exists in the Ubuntu Repositories and has been updated to almost the latest version.

Ubuntu is notorious for including outdated Nvidia Drivers in the official repositories, For a change this has changed now, It has the latest Nvidia-361 drivers in the repository. You could still use the Graphics Drivers PPA and bum the drivers up to Nvidia-364 which brings Wayland and Mir support, However Certain games like Shadow of Mordor have tremendous Screen tearing with that driver.

So if you take my advise stick to Nvidia-361 for a while and then upgrade.

 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-get install bumblebee bumblebee-nvidia primus nvidia-settings nvidia-361 (You could use nvidia-364 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-361
blacklist nvidia-361-updates
blacklist nvidia-experimental-361
# Workaround to make sure nvidia-uvm is removed as well
remove nvidia rmmod nvidia-uvm nvidia

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

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



nvidia-361 (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 361.42
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 361.42
OpenGL shading language version string: 4.50 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 361.42
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile 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.

Now there are chances that your Nvidia graphics card remains turned ON after primus or optirun exits. This is a known bug and you need to manually unload the Nvidia Module.

Nvidia-Unload Bug

above is a Link to the bug, should you face it.

Now it you face the bug, don't feel bad, bugs are there in all software, I am sure the developers are working to fix the bug.

OK, What is the workaround for this? If you are on another distro, chances are that you might have to compile bumblebee from source and add the lines of code to fix the issue. In Arch the you need to edit the PKGBUILD and add the lines of code as per the bug report and compile bumblebee-git and it would work just fine.

The problem though is that it is not easy. Since you are using Ubuntu, We have another solution called as NVIDIA-PRIME. (No other distribution has this except OpenSuse which partially works and you have to unload the module manually some times even though it should work)


Below are the Instructions.

Remove everything you installed in the previous steps using

sudo apt remove <packagename>

Reboot your laptop.

Login again and open up a terminal and run the commands.

sudo apt install nvidia-prime nvidia-361 (or nvidia-364 or higher in case you are using Graphics Drivers PPA)

Reboot your Laptop.

You should boot with your complete system using the Nvidia Graphics Card and your Graphics performance will be many times better than bumblebee in some games.

Now You don't want to be using Nvidia Card all the time, So, in the Dash search for Nvidia-Settings. Open Nvidia-Settings and browse to


Click PRIME PROFILES. you see two Options, One is NVIDIA (Performance Mode) and is selected and Second is INTEL (Power Saving Mode).

Click on Power Saving Mode enter your password in the Authentication dialog box. The Log out and Log in.

Now you are running only on INTEL GPU. If you want to flip back to NVIDIA GPU you can use the same process again and select NVIDIA and logout and login again.

Only caveat is that you need to logout and login and manually switch Graphics. Once you switch you stay on that card till you manually switch again.

Other than that this is a great solution and my personal favorite and something I am using right now (because of that bug)

Please leave your feedback in the comments section. 

Thanks for your time!