The Bumblebee package available in the official Ubuntu 16.04 repositories needs a tweak to work with Nvidia 361 graphics drivers. Furthermore, if you want to use a newer Nvidia graphics drivers version, such as 370 (which is currently in beta), the discrete card is not turned off, resulting in it being used all the time, and not just when running apps or games with "optirun", as it should.
So here's how to properly install and configure Bumblebee in Ubuntu 16.04, to get it to work with nvidia-361 and nvidia-370 (the latter from the Graphics Drivers PPA).
The instructions below should also work with Linux Mint 18.x, but I didn't test this in Linux Mint!
Update: the Nvidia Graphics Drivers PPA now also provides Nvidia 375 and 378 drivers. The instructions below work with these as well, but make sure to replace any instance o "nvidia-370" with the version from the PPA you use, in the instructions below!
Update 2: the instructions below now also include Ubuntu 16.10.
The instructions below should also work with Linux Mint 18.x, but I didn't test this in Linux Mint!
Update: the Nvidia Graphics Drivers PPA now also provides Nvidia 375 and 378 drivers. The instructions below work with these as well, but make sure to replace any instance o "nvidia-370" with the version from the PPA you use, in the instructions below!
Update 2: the instructions below now also include Ubuntu 16.10.
Bumblebee is a daemon for managing Optimus hybrid graphics chipsets. It allows running applications and games using the discrete GPU (on demand - e.g. using "optirun some-game").
Ubuntu already provides a way of switching between Intel and Nvidia GPUs, by using Nvidia Prime (with Nvidia Prime installed, you can select which GPU to use from Nvidia Settings > PRIME Profiles), but this sets the GPU for the whole desktop, and not just for specific applications and games. For instance, if you select Nvidia, the desktop and every application you run will use the Nvidia GPU.
For some (like me), using the whole desktop on the Nvidia GPU can cause excessive heating, making Bumblebee a better option for running games.
Install and configure Bumblebee in Ubuntu 16.04 or 16.10 / Linux Mint 18.x
Please read the whole article very carefully, and follow the instructions exactly as mentioned in this article. Misconfiguring Bumblebee can have results the desktop not loading, or the display manager not showing up, and you'll have to recover from this via TTY. So use this at your own risk and only if you know how to debug it and recover from any issues that may occur!
Bumblebee seems pretty unstable when it comes to getting it to work, so while these instructions have been tested on my laptop, it may not work for you (it can depend on hardware, installed packages and other factors). These instructions are for those familiar with Bumblebee, who know how to debug it. Don't install it unless you know exactly what you're doing.
Bumblebee seems pretty unstable when it comes to getting it to work, so while these instructions have been tested on my laptop, it may not work for you (it can depend on hardware, installed packages and other factors). These instructions are for those familiar with Bumblebee, who know how to debug it. Don't install it unless you know exactly what you're doing.
The instructions below assume you've already installed some Nvidia graphics drivers (nvidia-361 or nvidia-370).
I tested this on a Dell XPS L702x laptop running Ubuntu (w/ Unity) 16.04, with nvidia-361 from the official repositories (and Bumblebee from the official repositories), and with nvidia-370 from the Graphics Drivers PPA (with Bumblebee from the Bumblebee Development PPA).
1. Install Nvidia Prime and set it to "intel"
In my test under Ubuntu 16.04, not having Nvidia Prime installed and set to "intel" results in an xorg.conf file being created under /etc/X11/ upon each reboot (or LightDM restart), which causes a black login screen.
To install nvidia-prime and set it to use the Intel graphics card, use the following commands:
sudo apt install nvidia-prime
sudo prime-select intel
Do not use Nvidia Settings to set the Prime PROFILES to Nvidia, because it will cause issues after a reboot (in my test, it causes a black login screen)!
2. Install Bumblebee
In my test, I needed to edit a configuration file to get Bumblebee from the official repositories to work with nvidia-361 drivers (step 3).
For nvidia-370 from the Graphics Drivers PPA however, the Nvidia graphics card wasn't turned off (this can be checked with "cat /proc/acpi/bbswitch" - it should say "off" when no app is using the Nvidia graphics card, e.g. if you didn't run any app or game using "optirun") and I was unable to find a workaround for this.
I did get it to work though, by installing Bumblebee from its development PPA. So to get Bumblebee to work properly with nvidia-370 in Ubuntu 16.04 / Linux Mint 18.x, you'll need to install Bumblebee from THIS PPA.
If you want to use Bumblebee with nvidia-361, install Bumblebee from the official Ubuntu 16.04 / Linux Mint 18.x repositories:
sudo apt install bumblebee
To get Bumblebee to work with nvidia-370 in Ubuntu 16.04 / Linux Mint 18.x, install it from the Bumblebee Development PPA (read the PPA description before adding it!):
sudo add-apt-repository ppa:bumblebee/testing
sudo apt update
sudo apt install bumblebee
To install Bumblebee in Ubuntu 16.10, you don't need a PPA since the version in the official Ubuntu repositories already includes the patches available in the PPA. So to install Bumblebee in Ubuntu 16.10 from the official Ubuntu repositories, use the following command:
sudo apt install bumblebee
3. Blacklist the the Nvidia driver you're using by adding it to /etc/modprobe.d/bumblebee.conf (bit via AskUbuntu)
Open /etc/modprobe.d/bumblebee.conf with a text editor (as root) - I'll use Gedit below:
gksu gedit /etc/modprobe.d/bumblebee.conf
And at the end of the file, add the following:- for nvidia-361 (assuming you've installed Bumblebee from the official repositories; the Bumblebee package in the Bumblebee Development PPA already has this):
# 361
blacklist nvidia-361
blacklist nvidia-361-updates
blacklist nvidia-experimental-361
- for nvidia-370 (from the Graphics Drivers PPA):# 370
blacklist nvidia-370
blacklist nvidia-370-updates
blacklist nvidia-experimental-370
... and save the file.Important: if later on you install some newer Nvidia graphics drivers (e.g. nvidia-371, nvidia-372, etc.), you'll need to add them to /etc/modprobe.d/bumblebee.conf, in the same way as explained above, but for the new driver version.
4. Configure Bumblebee
Open the Bumblebee configuration file with a text editor (as root) - I'll use Gedit for the command below:
gksu gedit /etc/bumblebee/bumblebee.conf
... and in this file, change the following options so they look like below:- for nvidia-361:
- Driver=nvidia
- KernelDriver=nvidia-361
- LibraryPath=/usr/lib/nvidia-361:/usr/lib32/nvidia-361
- XorgModulePath=/usr/lib/nvidia-361/xorg,/usr/lib/xorg/modules
- for nvidia-370:
- Driver=nvidia
- KernelDriver=nvidia-370
- LibraryPath=/usr/lib/nvidia-370:/usr/lib32/nvidia-370
- XorgModulePath=/usr/lib/nvidia-370/xorg,/usr/lib/xorg/modules
... and save the file.
Important: just like step 2, if later on you install some newer Nvidia graphics drivers (e.g. nvidia-371, nvidia-372, etc.), you'll need to change all "nvidia-xxx" occurances in /etc/bumblebee/bumblebee.conf with the new driver.
Update (thanks to Philippe and user-az for the info!): it appears that the BusID is not set properly for some users, causing Bumblebee not to work. To check / correct this, open the /etc/bumblebee/xorg.conf.nvidia file as root with a text editor (I'll use Gedit again below):
gksu gedit /etc/bumblebee/xorg.conf.nvidia
And in this file, make sure that the "BusID" line is commented out (it shouldn't have a "#" sign in front of the line), and that it matches your Nvidia graphics bus ID. If it's not, change it, then save the file. To check the graphics bus ID, use the following command (make sure you look for the line with Nvidia, and not Intel):
lspci | egrep 'VGA|3D'
5. Reboot
That's it. After rebooting, the "cat /proc/acpi/bbswitch" command should display "OFF" as ouput, meaning that the discrete card is turned off by default.
To try out Bumblebee, use "optirun some_app_or_game". To configure the Nvidia settings for Bumblebee, launch the settings using the following command:
optirun -b none /usr/bin/nvidia-settings -c :8
I should also mention that if you later want to remove Bumblebee, make sure to purge it ("sudo apt purge bumblebee"), to make sure its configuration files are removed, or else you'll experience issues, like the Nvidia drivers remaining blacklisted.
If you encounter issues, see the DEBIAN.readme file (/usr/share/doc/bumblebee/README.Debian on Debian/Ubuntu systems with Bumblebee installed) which explains some possible solutions, as well as the Bumblebee wiki.
Extra tip: If you want to see which GPU is currently being used and manually turn the dedicated GPU on or off, you can use Nvidia Power Indicator. This is available in the main WebUpd8 PPA and it can be installed in Ubuntu or Linux Mint by using the following commands:
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt update
sudo apt install nvidia-power-indicator