Ubuntu 16.04 ultimate dual graphic card solution with newest nvidia proprietary drivers switchable without logout

Finally I got it working. Using both nvidia-prime and bumblebee at the same time to allow switches between the two graphic cards (intel and nvidia) in both per-application-without-logout and whole-system-with-logout manner. My cuda also stays working at both mode.

The following are the steps.

  1. Add newest nvidia-driver ppa: sudo add-apt-repository ppa:graphics-drivers/ppa;sudo apt update.

  2. Install the proprietary driver(in my case, 384, larger index should means newer) and nvidia-prime: sudo apt install nvidia-384 nvidia-prime.

  3. [optional] Add prime-indicator ppa and install sudo add-apt-repository ppa:nilarimogard/webupd8;sudo apt update;sudo apt install prime-indicator-plus;

  4. Reboot and the graphic cards should be able to be switchable with the indicator or x-org-setting from the dash menu. But it requires a reboot to perform the switch. If that’s not satisfactory and the user want more flexible control, proceed. If not, stop here.

  5. Install bbswitch and bumblebee: sudo apt install bbswitch-dkms bumblebee bumblebee-nvidia.

  6. Configure bumblebee to work.

    1
    2
    sudo gpasswd -a $USER bumblebee
    sudo systemctl enable bumblebeed

open the config file sudo gedit /etc/bumblebee/bumblebee.conf and edit:
Driver= $\rightarrow$ Driver=nvidia
Remember to replace all 384 to your driver index
KernelDriver=nvidia-384
LibraryPath=/usr/lib/nvidia-384:/usr/lib32/nvidia-384
XorgModulePath=/usr/lib/nvidia-384/xorg,/usr/lib/xorg/modules

open the config file /etc/modprobe.d/bumblebee.conf and add:

1
2
3
blacklist nvidia-384
blacklist nvidia-384-updates
blacklist nvidia-experimental-384

  1. Reboot and prey.

  2. If everything goes right, you should be able to use optirun COMMAND to run an application using the nvidia graphic card even if you disabled the card and set to use the intel graphic card in the nvidia-prime setting.

  3. Try optirun COMMAND or primusrun COMMAND and see if everything works. It’s said that the former is of better performances but its actually 3 times slower on my machine.

  4. Remember to turn off the power of nvidia GPU after using it through the indicator to save power.

2017/12/10

Add: After updating to nvidia-387, except changing the config files, a manual power on through prime indicator seems to be necessary everytime before use.

Add: To solve the error: Xlib: extension "GLX" missing on display ":8"., see here.