Dual graphic card configuration on Gentoo

Recently, I was experimenting with OpenGL 3.3 support on my intel GPU within the newly released mesa 10.0.2.

Vendor: ........... Intel Open Source Technology Center
Renderer: ......... Mesa DRI Intel(R) Ivybridge Mobile 
Version: .......... 3.3 (Core Profile) Mesa 10.0.2
GLSL version: ..... 3.30

Sadly, it turned out, that the rotating cube made of triangles I was playing with was not drawn correctly as you can observe on this video. It took me a lot of time to realize, that it could be not just an oversight from my side but as well an undiscovered yet issue in the driver which I was trying out. It was about time to recall that my laptop has a hybrid video card. So, I started to think about an opportunity to configure it as well, to be able to test my sample code on the second video card I have. And I did.

Vendor: ........... NVIDIA Corporation
Renderer: ......... GeForce GT 640M/PCIe/SSE2
Version: .......... 3.3.0 NVIDIA 331.38
GLSL version: ..... 3.30 NVIDIA via Cg compiler

Luckily for me, at the end if this story my sample code was running fine, all issues I have observed with the intel mesa driver went away. It does not for sure mean, that my code is written correctly, but at least it’s a good indication, that it could be the case.

So, if you have a hybrid video card, like I do, there is a good and well supported on Gentoo project named Bumblebee which allows you to launch any application using the mighty secondary video card, in my case it’s GeForce GT 640M/PCIe/SSE2. I decided to go with a proprietary nvidia-driver, and therefore added it to my video card’s list side by side with intel:

# cat /etc/portage/make.conf
VIDEO_CARDS="intel nvidia" 

Updated my system afterwards and finally emerged bumblebee.

# emerge -a1v bumblebee

Make sure that you add yourself to the bumblebee group:

# gpasswd -a <user> bumblebee

As I have mentioned earlier bumblebee is well supported on Gentoo, so nothing else were required. The default configuration this ebuild provide is quite good as well.

Afterwards you should be able to launch any application on the secondary video card you desire with:

$ optirun <your app>

If you hit an error while trying to launch it, similar to this one:

$ optirun glxgears -info
[ 2108.388910] [ERROR]The Bumblebee daemon has not been started yet or the socket path /var/run/bumblebee.socket was incorrect.
[ 2108.388931] [ERROR]Could not connect to bumblebee daemon - is it running?

then just make sure that you have started the bumblebeed service:

# systemctl start bumblebeed
# systemctl status bumblebeed
bumblebeed.service - Bumblebee C Daemon
   Loaded: loaded (/usr/lib64/systemd/system/bumblebeed.service; disabled)
   Active: active (running) since Fri 2014-01-24 15:13:05 CET; 4s ago
 Main PID: 1487 (bumblebeed)
   CGroup: /system.slice/bumblebeed.service
           └─1487 /usr/sbin/bumblebeed

Jan 24 15:13:05 pls systemd[1]: Starting Bumblebee C Daemon...
Jan 24 15:13:05 pls systemd[1]: Started Bumblebee C Daemon.
Jan 24 15:13:05 pls bumblebeed[1487]: [ 2264.079511] [INFO]/usr/sbin/bumblebeed 3.2.1 started