Issues with nVidia prime on Ubuntu

I consider myself a lucky owner of a laptop with a hybrid graphic card system. More precisely in my computer there is an Intel integrated graphic card and there is an dedicated nVidia graphic card. Both cards can be used on the computer in conjunction. This system is known as nVidia Optimus, and the idea loosely speaking is that most of the time you use the integrated graphic card unless the computer is doing some intensive graphics computation. The purpose is to be able to GPU intensive stuff like gaming, video editing and so on, and still have a computer that on average has a low power consumption.

Optimus support on Linux is limited and I am a Linux user so I have trouble taking advantage of the setup. The most advanced solution on Linux currently is bumblebee that let’s you run specific applications on the dedicated graphic card while the rest runs on the integrated graphic card. I personally am using nVidia PRIME because it is better supported on Ubuntu Gnome.

PRIME works as follows you can either boot into your computer in intel mode or nvidia mode. You can probably guess that in intel mode the dedicated card is not used at all, while in nvidia mode the dedicated card is used for everything. However I run into a bug recently.

The setup actually works fairly well. To use PRIME I interface the system via the following commands:

  1. Check which ‘mode’ I am in:
prime-select query
  1. Ask to be in ‘Intel’ mode at next reboot
prime-select intel
  1. Ask to be in ‘nVidia’ mode at next reboot
prime-select nvidia

When using the first command it will tell either intel, nvidia or unknown. The latter is not suppose to happen, except it did happen to me quite a lot. I was always in intel mode, PRIME would always say unknown and I couldn’t switch to nvidia.

This bug is related to a Linux kernel update. The following version works fine: 4.8.0-28. But the newer version 4.8.0-30 runs into the problem I described above. As far as I understand a change was introduced with power management on the PCI bus. If you run into the described problem please downgrading the kernel version to see if it still happens to you.