Bumblebee
zh-CN:Bumblebee From Bumblebee's FAQ:
Bumblebee is an effort to make NVIDIA Optimus enabled laptops work in GNU/Linux systems. Such feature involves two graphics cards with two different power consumption profiles plugged in a layered way sharing a single framebuffer.
Contents
Bumblebee: Optimus for Linux
Optimus Technology is an hybrid graphics implementation without a hardware multiplexer. The integrated GPU manages the display while the dedicated GPU manages the most demanding rendering and ships the work to the integrated GPU to be displayed. When the laptop is running on battery supply, the dedicated GPU is turned off to save power and prolong the battery life.
Bumblebee is a software implementation based on VirtualGL and a kernel driver to be able to use the dedicated GPU, which is not physically connected to the screen.
Bumblebee tries to mimic the Optimus technology behavior; using the dedicated GPU for rendering when needed and power it down when not in use. The present releases only support rendering on-demand, power-management is a work in progress.
The NVIDIA dedicated card is managed as a separate X server connected to a "fake" screen (the screen is configured but not used). The second server is called using VirtualGL as if it were a remote server. That said, you will need a series of steps to set-up the kernel driver, the X server and a daemon.
Installation
Before installing Bumblebee check your BIOS and activate Optimus (shareable graphics), if possible (BIOS doesn't have to provide this option), and install the intel driver for the secondary on board graphics card.
Installing Bumblebee with Intel / nvidia
- Install bumblebeeAUR ( bumblebee-systemdAUR if you are using systemd ) from AUR.
- Install the special nvidia package nvidia-utils-bumblebeeAUR for bumblebee.
- Install the nvidia-bumblebeeAUR ( You can install dkms-nvidiaAUR instead if you need it) from the AUR.
Installing Bumblebee with Intel / nouveau
Install nouveau and required packages first:
# pacman -S xf86-video-nouveau nouveau-dri mesa
- xf86-video-nouveau experimental 3D acceleration driver
- nouveau-dri Mesa classic DRI + Gallium3D drivers
- mesa Mesa 3-D graphics libraries
Now Install bumblebeeAUR or bumblebee-systemdAUR from AUR:
Start Bumblebee
In order to use Bumblebee it is necessary add yourself (and other users) to the bumblebee group:
# usermod -a -G bumblebee $USER
where $USER
is the login name of the user to be added. Then log off and on again to apply the group changes.
To start bumblebee automatically add it to your DAEMONS
array in /etc/rc.conf
DAEMONS=(... @bumblebeed)
For systemd users
# systemctl start bumblebeed.service
Enable on boot (Preferred method)
# systemctl enable bumblebeed.service
Finished - reboot system and use the shell program optirun
for Optimus NVIDIA rendering!
Usage
The command line programm optirun
shipped with bumblebee is your best friend for running applications on your Optimus NVIDIA card.
Test Bumblebee if it works with your Optimus system:
$ optirun glxgears
If it succeeds and the terminal you are running from mentions something about your NVIDIA - Optimus with Bumblebee is working!
General Usage:
$ optirun [options] <application> [application-parameters]
Some Examples:
Start Firefox accelerated with Optimus:
$ optirun firefox
Start Windows applications with Optimus:
$ optirun wine <windows application>.exe
Use NVIDIA Settings with Optimus:
$ optirun nvidia-settings -c :8
For a list of options for optirun
run:
$ optirun --help
Configuration
You can configure the behaviour of Bumblebee to fit your needs. Fine tuning like speed optimization, power managment and other stuff can be configured in /etc/bumblebee/bumblebee.conf
Optimizing Speed
Bumblebee renders frames for your Optimus NVIDIA card in an invisible X Server with VirtualGL and transports them back to your visible X Server.
Frames will be compressed before they are transported - this saves bandwith and can be used for speedup optimization of bumblebee:
To use an other compression method for a single application:
$ optirun -c <compress-method> application
The method of compres will affect performance in the GPU/GPU usage. Compressed methods (such as jpeg
) will load the CPU the most but will load GPU the minimum necessary; uncompressed methods loads the most on GPU and the CPU will have the minimum load possible.
Compressed Methods are: jpeg
, rgb
, yuv
Uncompressed Methods are: proxy
, xv
To use a standard compression for all applications set the VGLTransport
to <compress-method>
in /etc/bumblebee/bumblebee.conf
/etc/bumblebee/bumblebee.conf
... [optirun] VGLTransport=proxy ...
You can also play with the way VirtualGL reads back the pixels from your graphic card. Setting VGL_READBACK
environment variable to pbo
should increase the performance. Compare these two:
# PBO should be faster. VGL_READBACK=pbo optirun glxspheres # The default value is sync. VGL_READBACK=sync optirun glxspheres
Power Management
The goal of power management feature is to turnoff the NVIDIA card when it is not used by bumblebee anymore.
To enable power managment for bumblebee install bbswitchAUR from AUR.
Set the PMMethod
to bbswitch
in the driver section of /etc/bumblebee/bumblebee.conf
:
/etc/bumblebee/bumblebee.conf
[bumblebeed] KeepUnusedXServer=false ... [driver-nvidia] PMMethod=bbswitch ... [driver-nouveau] PMMethod=bbswitch ...
Default power state of NVIDIA card
Set load_state
and unload_state
module options according to your needs (see bbswitch documentation).
/etc/modprobe.d/bbswitch.conf
options bbswitch load_state=0 unload_state=0
Just restart bumblebee daemon to activate power managment:
# systemctl restart bumblebeed.service
Enable NVIDIA card during shutdown
The NVIDIA card may not correctly initialize during boot if the card was powered off when the system was last shutdown. One option is to set TurnCardOffAtExit=false
in /etc/bumblebee/bumblebee.conf
, however this will enable the card everytime you stop the Bumblebee daemon, even if done manually. To ensure that the NVIDIA card is always powered on during shutdown, add the following hook function (if using bbswitchAUR):
/etc/rc.d/functions.d/nvidia-card-enable
nvidia_card_enable() { BBSWITCH=/proc/acpi/bbswitch stat_busy "Enabling NVIDIA GPU" if [ -w ${BBSWITCH} ]; then echo ON > ${BBSWITCH} stat_done else stat_fail fi } add_hook shutdown_poweroff nvidia_card_enable
Multiple monitors
You can set up multiple monitors with xorg.conf. Set them to use the Intel card, but Bumblebee can still use the NVIDIA card. One example configuration is below for two identical screens with 1080p resolution and using the HDMI out.
/etc/X11/xorg.conf
Section "Screen" Identifier "Screen0" Device "intelgpu0" Monitor "Monitor0" DefaultDepth 24 Option "TwinView" "0" SubSection "Display" Depth 24 Modes "1980x1080_60.00" EndSubSection EndSection Section "Screen" Identifier "Screen1" Device "intelgpu1" Monitor "Monitor1" DefaultDepth 24 Option "TwinView" "0" SubSection "Display" Depth 24 Modes "1980x1080_60.00" EndSubSection EndSection Section "Monitor" Identifier "Monitor0" Option "Enable" "true" EndSection Section "Monitor" Identifier "Monitor1" Option "Enable" "true" EndSection Section "Device" Identifier "intelgpu0" Driver "intel" Option "XvMC" "true" Option "UseEvents" "true" Option "AccelMethod" "UXA" BusID "PCI:0:2:0" EndSection Section "Device" Identifier "intelgpu1" Driver "intel" Option "XvMC" "true" Option "UseEvents" "true" Option "AccelMethod" "UXA" BusID "PCI:0:2:0" EndSection
You need to probably change the BusID:
$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
The BusID is 0:2:0
CUDA Without Bumblebee
This is not well documented, but you do not need Bumblebee to use CUDA and it may work even on machines where optirun fails. For a guide on how to get it working with the Lenovo IdeaPad Y580 (which uses the GeForce 660M), see: https://wiki.archlinux.org/index.php/Lenovo_IdeaPad_Y580#NVIDIA_Card. Those instructions are very likely to work with other machines (except for the acpi-handle-hack part, which may not be necessary).
Troubleshooting
[VGL] ERROR: Could not open display :8
There is a known problem with some wine applications that fork and kill the parent process without keeping track of it (for example the free to play online game "Runes of Magic")
A workaround for this problem is:
$ optirun bash $ optirun wine <windows program>.exe
If using NVIDA drivers a fix for this problem is to edit /etc/bumblebee/xorg.conf.nvidia
and change Option ConnectedMonitor
to CRT-0
.
[ERROR]Cannot access secondary GPU
No devices detected.
In some instances, running optirun will return:
[ERROR]Cannot access secondary GPU - error: [XORG] (EE) No devices detected. [ERROR]Aborting because fallback start is disabled.
In this case, you will need to move the file /etc/X11/xorg.conf.d/20-intel.conf
to somewhere else. Restart the bumblebeed daemon, and it should work.
It could be also necessary to comment the driver line in /etc/X11/xorg.conf.d/10-monitor.conf
.
If you're using the nouveau driver you could try switching to the nVidia driver.
NVIDIA(0): Failed to assign any connected display devices to X screen 0
If the console output is:
[ERROR]Cannot access secondary GPU - error: [XORG] (EE) NVIDIA(0): Failed to assign any connected display devices to X screen 0 [ERROR]Aborting because fallback start is disabled.
You can change this line in /etc/bumblebee/xorg.conf.nvidia
:
Option "ConnectedMonitor" "DFP"
to
Option "ConnectedMonitor" "CRT"
Change KeepUnusedXServer
in /etc/bumblebee/bumblebee.conf
from false
to true
. Your program forks into background and bumblebee don't know anything about it.
Video tearing
Video tearing is a somewhat common problem on Bumblebee. To fix it, you need to enable vsync. It should be enabled by default on the Intel card, but verify that from Xorg logs. To check whether or not it is enabled for nvidia, run
$ optirun nvidia-settings -c :8
X Server XVideo Settings -> Sync to VBlank
and OpenGL Settings -> Sync to VBlank
should both be enabled. The Intel card has in general less tearing, so use it for video playback. Especially use VA-API for video decoding (e.g. mplayer-vaapi
and with -vsync
parameter).
Refer to the Intel article on how to fix tearing on the Intel card.
If it is still not fixed, try to disable compositing from your desktop environment. Try also disabling triple buffering.
Important Links
Join us at #bumblebee at freenode.net