Saturday, 11 June 2011

Linux Hybrid Graphics: Current Status

Optimus and multi-GPU computers
A while ago, nVidia introduced what they call Optimus. This is a way to use two graphics cards on one machine. One of the cards is typically a low-power Intel or nVidia card, and the other one a high-performance, more energy hungry card. The Optimus laptop would then only do graphics on the high-performance card when the 3D application seemed to require more performance. This would be seamless, and the low-power card would be on 100% of the time.
At about the same time, multi-GPU laptops such as the Asus UL30Vt without the Optimus technology entered the market. These work slightly differently. The high-performance card is separate from the low-power card, and they can be switched when no 3D applications are running. This switches one card off and enables the other.

On Linux
That was the status on Windows. On Linux, nVidia provided no support for either type of multi-GPU machines. However, with the efforts of several Linux people, we now have solutions. asus-switcheroo and the vga-switcheroo kernel mechanism allow one to switch between two different graphics cards, provided that one first logs out. This is because a running X session locks a card so that it cannot be switched off. More detail and a solution for easy switching is at the hybrid graphics wiki. Now, this is not seamless, and rather cumbersome, since one is forced to log out in order to switch cards. Also, this only works on the non-Optimus machines. For those with Optimus, one would use Bumblebee. This is basically an X server that runs on the high-performance card, and copies its output to the screen that runs on the low-power card. With some acpi magic Bumblebee can turn on the high-performance card when you run a demanding application, and turn it off when it stops running. At the moment, this needs to be done manually.  Instead of running for example google earth with "googleearth" one would run it with "optirun32 googleearth". The 32 comes from the fact that google earth is a 32-bit application. If you run 64-bit applications on a 64-bit Linux, you would use simply e.g. "optirun mplayer".

On my UL30Vt, I have combined Bumblebee, acpi_call and asus-switcheroo, allowing me to run applications on the high-performance card using the optirun and optirun32 commands. The high-performance is turned off when these applications are not run, saving battery. I use the asus-switcheroo and acpi_call to turn off the high-performance card when the computer is started, so that I get 10 hours of battery life with Wifi turned off. If I want a fully high-performance desktop, or to use the HDMI port, I type the word "nvidia" into a special file called switcheroo.txt, and log out. The system will then switch the cards and give me a session running with the high-performance nVidia card.

On Linux, one can run demanding applications with the high-performance card manually. One can keep the high-performance card off at other times, saving battery. On multi-GPU non-Optimus machines, one can also switch cards after logging out.