For those unaware, NVIDIA Optimus is a technology that allows integrated Intel graphics and a discrete NVIDIA graphics card to be built into the same computer (generally a laptop) and switch between the two on-demand. This same technology is also the cause of Linus Torvalds' infamous "finger" gesture directed at NVIDIA themselves. So it's no secret that NVIDIA Optimus technology has a somewhat controversial relationship with the Linux platform. So how is the state of affairs currently?
The idea of NVIDIA Optimus isn't a bad one. When the extra power of the NVIDIA graphics chip isn't needed, only the integrated Intel GPU is utilized. This means everything, including the operating system itself, actually uses the Intel GPU all the time. It's only when, for example, you play an intensive 3D video game or rendering software that the NVIDIA GPU comes to life and does all the graphical processing for that software or program. The rest of the time, the NVIDIA GPU is simply switched off.
The advantage to this is obvious: you get the power saving features and less heat generated by the Intel GPU the majority of the time, but still have the full power of a dedicated NVIDIA GPU available when you need it.
On Microsoft Windows, this pretty much works as expected. The NVIDIA driver seems to have a "whitelist" of programs (the majority being games, of course) which automatically switches on the NVIDIA GPU when those programs are run.
On Linux, it's a tad more complicated...
Simply put, there is no actual official NVIDIA support for Optimus technology for Linux. Or at least, not completely. Until recently, there was none at all. As of 2013, NVIDIA did start to provide initial support for Optimus, but it is extremely barebones and arguably doesn't actually properly implement the Optimus features as it's meant to be.
But let's look at the current options for running an NVIDIA Optimus-enabled computer with Linux...
Initial Official NVIDIA Optimus Support:
This is what I mentioned above and on an Ubuntu system you'll find it most easily in the form of a package called "nvidia-prime". Other distros may require you to do some manual Xorg trickery to get it to work. Anyway, basically the official NVIDIA proprietary driver for Linux does now include an option (as long as nvidia-prime and/or Xorg is setup correctly) to switch between the Intel GPU and the NVIDIA GPU in the NVIDIA Control Panel. However, this is not real-time switching. You do have to log out and log back in for the change to take effect, so in the end you can only choose to use one GPU or the other at any one time. There is no dynamic switching. On the other hand if you don't care about battery life or heat or they aren't really a factor for you, you could just choose to use the NVIDIA GPU all the time, which is probably what a lot of heavy gamers would choose to do.
Depending on your computer, this option may not even be available. Some BIOS' allow you to actually turn off the Intel GPU and simply use the NVIDIA GPU, as if it were just a conventional system with a dedicated GPU. In this case, on Linux, you could turn off the Intel GPU and then your OS will only see the NVIDIA GPU. Then you just install the NVIDIA driver as you normally would and it should work as if Optimus never existed. The end result should be similar to the initial Optimus support mentioned above, when using the NVIDIA GPU full-time at least.
If you don't choose to the use the proprietary NVIDIA driver, however, the open-source Nouveau driver does actually provide most of the Optimus functionality out of the box through a technology called PRIME. You may have to still execute a line or two of commands in a terminal, but it is arguably the easiest and most out of the box solution. See this Arch Linux wiki entry on PRIME for more information. The downside is obvious though - Nouveau will suffer dramatically in terms of performance compared to the proprietary NVIDIA driver and has no power-saving features either.
When it comes to Optimus-like functionality with the proprietary NVIDIA driver, the Bumblebee project is probably the hero of the bunch. Bumblebee is actually a quite clever reverse-engineered effort to implement NVIDIA Optimus support on Linux as close as possible. Basically you have to install the Bumblebee packages on your Linux distribution of choice, but that is really the majority of the work you should have to do. With Bumblebee, your system will run entirely on the Intel GPU (as it should) and the NVIDIA GPU will be switched off, UNTIL you decide you need to run an application on the NVIDIA GPU. Unlike the Optimus support in Microsoft Windows, the NVIDIA GPU won't be activated automatically depending on application. Instead, you often need to prepend Bumblebee's default command "optirun" (or primusrun, an alternative Bumblebee loader with better performance that is fast becoming the preferred) before a program you wish to run. For example, if you wanted to run a game or program on the NVIDIA GPU, you would do as follows in a terminal:
optirun <program name>
The NVIDIA graphics card will then automatically power up and all graphical processing will take place on that chipset before being sent back to your display. Once you exit your program, the NVIDIA card is switched off again.
For performance AND power saving, this is clearly still the easiest way of utilizing the Optimus technology. However, it does mean you have to use the optirun/primusrun commands before each and every program you wish to load onto the NVIDIA GPU, which you may find tedious.
About 6 months ago I purchased a new ASUS N550J laptop. It has an Intel Core i7 CPU and has a dedicated NVIDIA GeForce GTX 850M. Hmm, an Intel CPU and an NVIDIA graphics card... yes, you guessed it... Optimus! I hadn't had any experience with Optimus before and to be honest, I just expected I could install the NVIDIA proprietary driver like I would any other computer with an NVIDIA graphics card. Wrong.
If your system is NVIDIA Optimus-enabled, that simply won't work that way in Linux. Your Linux distribution will see both the integrated Intel GPU and the NVIDIA card, but will run on the Intel card by default out of the box. If you then install the NVIDIA driver like you normally would, you will probably just end up with a black screen. Unless, of course, your BIOS allows switching one or the other completely off. Mine did not, however.
Long story short, I've tried most of the methods described above with varying degrees of success. None are perfect. As someone who doesn't utilize my laptop battery all that often (and the ASUS laptop seems to have fairly effective cooling anyway) I did try to simply exclusively use the NVIDIA graphics card. With the BIOS method ruled out, my choice was basically left to either using the Nouveau support or the NVIDIA initial support in the form of nvidia-prime.
Nouveau doesn't really fulfill the performance requirement, especially considering I play some demanding games that have recently been released for Linux, so my only option was the NVIDIA proprietary driver.
The result was... unsatisfactory. Sure, everything was running just fine on the NVIDIA GPU. But that in itself was a downside. Again, I don't mind the power consumption or extra heat too much, but exclusively using the NVIDIA card actually introduced horrific screen tearing, even on my desktop (GNOME 3). I can't stand screen tearing at the best of times, plus I felt desktop performance felt much smoother not only in terms of lack of screen tearing, but simply fluidity, with the Intel GPU.
This left me with using Bumblebee. To be honest, I've found Bumblebee to be the best balance available for someone in my position with Optimus on Linux. My laptop runs smooth and consistent as it should on the Intel GPU, but I can use the NVIDIA GPU when I need to. This means my desktop shell in GNOME is smooth and silky and tear-free, including while watching movies and the like, but I can still play a demanding game thanks to Bumblebee off-loading it to the NVIDIA GPU. Ironically, even a program running through Bumblebee still, in my experience, tears less than when using the NVIDIA GPU/driver exclusively.
The downside is what I mentioned earlier in the Bumblebee description. I personally use "primusrun" (which comes from the package called "primus", a shared library that is lower overhead compared to the default "optirun") which means I have to prepend that command to any program I wish to run on the NVIDIA card. In Steam, this means I have to add:
to the "launch options" of every game in my Steam library. On the plus side, this means every time I launch said game in the Steam UI after adding that line, it will automatically execute primusrun (Bumblebee). Of course if the game is less demanding and runs just fine on the integrated Intel GPU (which are no slouches these days), there's no need to do anything.
Some users of Bumblebee in the past have complained about inconsistent performance and even some programs not wanting to launch though the Bumblebee helper programs (eg. optirun/primusrun) at all, for various reasons. Knowing this before I started using Bumblebee, I was quite concerned I would be in for a bad time.
Thankfully, however, I've found performance to be generally just fine, possibly due to the improvements to the primusrun program. Games that I have played such as Bioshock: Infinite, Borderlands 2 and Metro: Last Light have run really well (although the latter would not launch on Bumblebee until the primusrun library was patched, but that was fixed fairly quickly) and those are fairly recent and demanding games. So, while some programs/games will occasionally have issue with Bumblebee, there's usually a work-around or a patch that comes along and quickly fixes the problem.
So, should Linus still give NVIDIA the middle finger? Is the state of NVIDIA Optimus still bad on Linux?
Well, let's be honest, it's still far from ideal. The only close-to-true Optimus functionality we can get on Linux is either the Nouveau PRIME support or the Bumblebee project, both of which are community FOSS efforts. Of course, this shows what the community is capable of and I find it impressive that we can use Optimus at all, let alone the fact I find Bumblebee to be quite seamless and pleasant enough to use, if not a little tedious with all the command usage.
NVIDIA have reportedly given some assistance to the Bumblebee project itself, where they can, and they have at least provided initial Optimus support but let's be honest: the NVIDIA implementation is not true dynamic switching and still requires far too much low level tinkering to make it work if you're on a non-Ubuntu distribution.
In summary, NVIDIA support for their Optimus technology on Linux is still not good enough, but at least something actually exists these days. For now Bumblebee or Nouveau really seems to be only the viable solutions if you want actual dynamic graphics switching, and only the former if you want true power-saving functionality.
Hopefully things will improve in future, but at least for now, thanks to the effort of the community especially, things are workable.