2015-05-31

Created page with "From Bumblebee's [https://github.com/Bumblebee-Project/Bumblebee/wiki/FAQ FAQ]: "''Bumblebee is an effort to make NVIDIA Optimus enabled laptops work in GNU/Linux systems. Su..."

New page

From Bumblebee's [https://github.com/Bumblebee-Project/Bumblebee/wiki/FAQ 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.''"

== Bumblebee: Optimus for Linux ==

[http://www.nvidia.com/object/optimus_technology.html Optimus Technology] is an ''[http://hybrid-graphics-linux.tuxfamily.org/index.php?title=Hybrid_graphics 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. It has also been tested successfully with desktop machines with Intel integrated graphics and an nVidia dedicated graphics card.

Bumblebee is a software implementation comprising of two parts:

* Render programs off-screen on the dedicated video card and display it on the screen using the integrated video card. This bridge is provided by VirtualGL or primus (read further) and connects to a X server started for the discrete video card.

* Disable the dedicated video card when it is not in use (see the [[#Power management|Power management]] section)

It 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, automatically starting a program with the discrete video card based on workload is not implemented.

== Installation ==

Before installing Bumblebee, check your BIOS and activate Optimus (older laptops call it "switchable graphics") if possible (BIOS doesn't have to provide this option) and install the [[Intel graphics|Intel driver]] for the secondary on board graphics card.

{{Note|Don't need to install any packages listed below. They are already shipped in the distribution just check their presence) }}

* {{Pkg|bumblebee}} - The main package providing the daemon and client programs.

* {{Pkg|bbswitch}} - Disables NVIDIA discrete graphics card when it is not used (already present in your system, kernel dependent).

* {{Pkg|primus}} - A render/display bridge. Only one of them is necessary, but installing both of them side-by-side is alright.

* {{Pkg|virtualgl}} - Test program '''glxspheres''' and '''glxgears'''.

=== Installing Bumblebee with Intel/NVIDIA ===

Install:

* {{Pkg|bumblebee}} - The main package providing the daemon and client programs.

* {{Pkg|mesa}} - An open-source implementation of the '''OpenGL''' specification.

* {{Pkg|xf86-video-intel}} - Intel driver.

* {{Pkg|nvidia-drivers}} - NVIDIA driver.

* {{Pkg|nvidia-drivers}} - NVIDIA userspace.

Check if the '''nouveau''' driver is blacklisted in /etc/modprobe.d/blacklist.conf:

blacklist nouveau

and be sure that nvidia is not blacklisted

=== Installing Bumblebee with Intel/Nouveau ===

{{Note|This method is deprecated and will most likely not work anymore. Use the nvidia module instead. If you want nouveau, use [[PRIME]].}}

Install:

* {{Pkg|nouveau}} - experimental 3D acceleration driver.

Blacklist the '''nvidia''' driver in /etc/modprobe.d/blacklist.conf:

blacklist nvidia

and be sure that nouveau is not blacklisted

== Usage ==

=== Test ===

Test Bumblebee if it works with your Optimus system:

$ optirun glxgears -info

If it fails, try the following commands:

$ optirun glxspheres

If the window with animation shows up - Optimus with Bumblebee is working.

=== General usage ===

$ optirun [options] ''application'' [application-parameters]

For example, start Windows applications with Optimus:

$ optirun wine application.exe

For another example, open NVIDIA Settings panel with Optimus:

$ optirun -b none nvidia-settings -c :8

For a list of the options for '''optirun''', view its manual page:

$ man optirun

== Configuration ==

You can configure the behaviour of Bumblebee to fit your needs. Fine tuning like speed optimization, power management and other stuff can be configured in '''/etc/bumblebee/bumblebee.conf'''

=== Optimizing speed ===

==== Using VirtualGL as bridge ====

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 bandwidth and can be used for speed-up optimization of bumblebee:

To use an other compression method for a single application:

$ optirun -c ''compress-method'' application

The method of compress will affect performance in the GPU/CPU usage. Compressed methods will mostly load the CPU. However, uncompressed methods will mostly load the GPU.

Compressed methods

:*jpeg

:*rgb

:*yuv

Uncompressed methods

:*proxy

:*xv

Here is a performance table tested with [[Asus N550JV]] laptop:

{| class="wikitable"

! Command !! FPS !! Score !! Min FPS !! Max FPS

|-

| optirun unigine-heaven || 25.0 || 630 || 16.4 || 36.1

|-

| optirun -c jpeg unigine-heaven || 24.2 || 610 || 9.5 || 36.8

|-

| optirun -c rgb unigine-heaven || 25.1 || 632 || 16.6 || 35.5

|-

| optirun -c yuv unigine-heaven || 24.9 || 626 || 16.5 || 35.8

|-

| optirun -c proxy unigine-heaven || 25.0 || 629 || 16.0 || 36.1

|-

| optirun -c xv unigine-heaven || 22.9 || 577 || 15.4 || 32.2

|}

{{Note|Lag spikes occurred when jpeg compression method was used.}}

To use a standard compression for all applications, set the '''VGLTransport''' to ''compress-method'' in '''/etc/bumblebee/bumblebee.conf''':

{{hc|/etc/bumblebee/bumblebee.conf|2=

[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 glxgears

# The default value is sync.

VGL_READBACK=sync optirun glxgears

{{Note|CPU frequency scaling will affect directly on render performance}}

==== Primusrun ====

{{ic|primusrun}} (package {{Pkg|primus}}) is becoming the default choice, because it is power consuming and provides a better performance than {{ic|optirun}}. Currently you need to run this program separately (it does not accept options unlike {{ic|optirun}}), but in the future it will be started by optirun.

Usage:

$ primusrun glxgears

{{Tip|Refer to [[#Primusrun_mouse_delay.2Fdisable_VSYNC]] if you want to disable {{ic|VSYNC}}. It can also remove mouse input delay lag and slightly increase the performance.}}

=== Power management ===

The goal of power management feature is to turn off the NVIDIA card when it is not used by bumblebee any more.

If {{Pkg|bbswitch}} is installed, it will be detected automatically when the Bumblebee daemon starts. No additional

configuration is necessary.

==== Default power state of NVIDIA card using bbswitch ====

The default behavior of bbswitch is to leave the card power state unchanged. {{ic|bumblebeed}} does disable

the card when started, so the following is only necessary if you use bbswitch without bumblebeed.

Set {{ic|load_state}} and {{ic|unload_state}} module options according to your needs (see [https://github.com/Bumblebee-Project/bbswitch bbswitch documentation]).

{{hc|/etc/modprobe.d/bbswitch.conf|2=

options bbswitch load_state=0 unload_state=1

}}

==== 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 {{ic|TurnCardOffAtExit=false}} in {{ic|/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 [[En:HOWTO:_systemd]] service (if using {{pkg|bbswitch}}):

{{hc|/etc/systemd/system/nvidia-enable.service|2=

[Unit]

Description=Enable NVIDIA card

DefaultDependencies=no

[Service]

Type=oneshot

ExecStart=/bin/sh -c 'echo ON > /proc/acpi/bbswitch'

[Install]

WantedBy=shutdown.target

}}

Then enable the service by running {{ic|systemctl enable nvidia-enable.service}} at the root prompt.

=== Multiple monitors ===

==== Outputs wired to the Intel chip ====

If the port (DisplayPort/HDMI/VGA) is wired to the Intel chip, 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.

{{hc|/etc/X11/xorg.conf|2=

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

Section "Device"

Identifier "nvidiagpu1"

Driver "nvidia"

BusID "PCI:0:1:0"

EndSection

}}

You need to probably change the BusID for both the Intel and the NVIDIA card.

{{hc|<nowiki>$ lspci | grep VGA</nowiki>|

00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)

}}

The BusID is 0:2:0

==== Output wired to the NVIDIA chip ====

On some notebooks, the digital Video Output (HDMI or DisplayPort) is hardwired to the NVIDIA chip. If you want to use all the displays on such a system simultaniously, you have to run 2 X Servers. The first will be using the Intel driver for the notebooks panel and a display connected on VGA. The second will be started through optirun on the NVIDIA card, and drives the digital display.

There are currently several instructions on the web how such a setup can be made to work. One can be found on the bumblebee [https://github.com/Bumblebee-Project/Bumblebee/wiki/Multi-monitor-setup wiki page]. Another approach is described below.

===== Using intel-virtual-output =====

This method should obsolete the use of ''xf86-video-intel-virtual-crtc'' and ''hybrid-screenclone''. ''intel-virtual-output'' is a tool provided in the ''xf86-video-intel driver'' set, as of v2.99. When run in a terminal, it will daemonize itself unless the {{ic|-f}} switch is used. Once the tool is running, it activates Bumblebee (Bumblebee can be left as default install), and any displays attached will be automatically detected, and manageable via any desktop display manager such as xrandr or KDE Display.

{{Note|In {{ic|/etc/bumblebee/xorg.conf.nvidia}} change the lines {{ic|UseEDID}} and {{ic|Option "AutoAddDevices" "false"}} to {{ic|"true"}}, if you are having trouble with device resolution detection.}}

Commandline usage is as follows:

intel-virtual-output [OPTION]... [TARGET_DISPLAY]...

-d <source display> source display

-f keep in foreground (do not detach from console and daemonize)

-b start bumblebee

-a connect to all local displays (e.g. :1, :2, etc)

-S disable use of a singleton and launch a fresh intel-virtual-output process

-v all verbose output, implies -f

-V <category> specific verbose output, implies -f

-h this help

If no target displays are parsed on the commandline, ''intel-virtual-output'' will attempt to connect to any local display and then start bumblebee.[http://cgit.freedesktop.org/xorg/driver/xf86-video-intel/tree/tools/]

The advantage of using ''intel-virtual-output'' in foreground mode is that once the external display is disconected, ''intel-virtual-output'' can then be killed and bumblebee will disable the nvidia chip.

Games can be run on the external screen by first exporting the display {{ic|1=export DISPLAY=:8}}, and then running the game with {{ic|optirun ''game_bin''}}, however, cursor and keyboard are not fully captured. Use {{ic|1=export DISPLAY=:0}} to revert back to standard operation.

== CUDA without Bumblebee==

You can use CUDA without bumblebee. All you need to do is ensure that the nvidia card is on:

# tee /proc/acpi/bbswitch <<< ON

Now when you start a CUDA application it is going to automatically load all the necessary modules.

To turn off the nvidia card after using CUDA do:

# rmmod nvidia_uvm

# rmmod nvidia

# tee /proc/acpi/bbswitch <<< OFF

== Troubleshooting ==

{{Note|Please report bugs at [https://github.com/Bumblebee-Project/Bumblebee Bumblebee-Project]'s GitHub tracker as described in its [https://github.com/Bumblebee-Project/Bumblebee/wiki/Reporting-Issues wiki].}}

=== [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")

This is a known problem with VirtualGL. As of bumblebee 3.1, so long as you have it installed, you can use Primus as your render bridge:

$ optirun -b primus wine ''windows program''.exe

If this does not work, an alternative walkaround for this problem is:

$ optirun bash

$ optirun wine ''windows program''.exe

If using NVIDIA drivers a fix for this problem is to edit {{ic|/etc/bumblebee/xorg.conf.nvidia}} and change Option {{ic|ConnectedMonitor}} to {{ic|CRT-0}}.

=== [ERROR]Cannot access secondary GPU: No devices detected ===

In some instances, running {{ic|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 {{ic|/etc/X11/xorg.conf.d/20-intel.conf}} to somewhere else, [[restart]] the bumblebeed daemon and it should work. If you do need to change some features for the Intel module, a workaround is to merge {{ic|/etc/X11/xorg.conf.d/20-intel.conf}} to {{ic|/etc/X11/xorg.conf}}.

It could be also necessary to comment the driver line in {{ic|/etc/X11/xorg.conf.d/10-monitor.conf}}.

If you're using the {{ic|nouveau}} driver you could try switching to the {{ic|nvidia}} driver.

You might need to define the NVIDIA card somewhere (e.g. file {{ic|/etc/X11/xorg.conf.d}}), using the correct {{ic|BusID}} according to {{ic|lspci}} output:

{{bc|

Section "Device"

Identifier "nvidiagpu1"

Driver "nvidia"

BusID "PCI:0:1:0"

EndSection

}}

==== 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 {{ic|/etc/bumblebee/xorg.conf.nvidia}}:

Option "ConnectedMonitor" "DFP"

to:

Option "ConnectedMonitor" "CRT"

==== Failed to initialize the NVIDIA GPU at PCI:1:0:0 (GPU fallen off the bus / RmInitAdapter failed!) ====

Add {{ic|1=rcutree.rcu_idle_gp_delay=1}} to the [[kernel parameters]] of the [[bootloader]] configuration (see also the Archlinux original [https://bbs.archlinux.org/viewtopic.php?id=169742 BBS post] for a configuration example).

==== Could not load GPU driver ====

If the console output is:

[ERROR]Cannot access secondary GPU - error: Could not load GPU driver

and if you try to load the nvidia module you get:

modprobe nvidia

modprobe: ERROR: could not insert 'nvidia': Exec format error

You should check if you have the kernel module installed correctly.

==== NOUVEAU(0): [drm] failed to set drm interface version ====

Consider switching to the official nvidia driver. As commented [https://github.com/Bumblebee-Project/Bumblebee/issues/438#issuecomment-22005923 here], nouveau driver has some issues with some cards and bumblebee.

=== /dev/dri/card0: failed to set DRM interface version 1.4: Permission denied ===

This could be worked around by appending following lines in {{ic|/etc/bumblebee/xorg.conf.nvidia}} (see [https://github.com/Bumblebee-Project/Bumblebee/issues/580 here]):

{{bc|

Section "Screen"

Identifier "Default Screen"

Device "DiscreteNvidia"

EndSection

}}

=== ERROR: ld.so: object 'libdlfaker.so' from LD_PRELOAD cannot be preloaded: ignored ===

You probably want to start a 32-bit application with bumblebee on a 64-bit system. See the "Note" box in [[#Installation|Installation]].

=== Fatal IO error 11 (Resource temporarily unavailable) on X server ===

Change {{ic|KeepUnusedXServer}} in {{ic|/etc/bumblebee/bumblebee.conf}} from {{ic|false}} to {{ic|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

{{ic|1=X Server XVideo Settings -> Sync to VBlank}} and {{ic|1=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. {{ic|mplayer-vaapi}} and with {{ic|-vsync}} parameter).

Refer to the [[Intel#Video_tearing|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.

=== Bumblebee cannot connect to socket ===

You might get something like:

$ optirun glxspheres

{{hc|$ optirun glxspheres|

[ 1648.179533] [ERROR]You've no permission to communicate with the Bumblebee daemon. Try adding yourself to the 'bumblebee' group

[ 1648.179628] [ERROR]Could not connect to bumblebee daemon - is it running?

}}

If you are already in the {{ic|bumblebee}} group ({{ic|<nowiki>$ groups | grep bumblebee</nowiki>}}), you may try removing the socket {{ic|/var/run/bumblebeed.socket}}.

=== Primusrun mouse delay/disable VSYNC ===

For {{ic|primusrun}}, {{ic|VSYNC}} is enabled by default and as a result, it could make mouse input delay lag or even slightly decrease performance. Test {{ic|primusrun}} without {{ic|VSYNC}}:

$ vblank_mode=0 primusrun glxgears

If you want to use it instead of {{ic|primusrun}}, create new file:

{{hc|/usr/bin/optiprime|2=<nowiki>

#!/bin/sh

vblank_mode=0 primusrun "$@"

</nowiki>}}

Make it executable:

# chmod +x /usr/bin/optiprime

Usage:

$ optiprime glxgears

In conclusion, it doesn't make significant performance improvement, but as mentioned above, it should remove mouse input delay lag.

{| class="wikitable"

! Command !! FPS !! Score !! Min FPS !! Max FPS

|-

| optiprime unigine-heaven || 31.5 || 793 || 22.3 || 54.8

|-

| primusrun unigine-heaven || 31.4 || 792 || 18.7 || 54.2

|}

''Tested with [[Asus N550JV]] laptop.''

== See also ==

* [http://www.bumblebee-project.org Bumblebee project repository]

* [http://wiki.bumblebee-project.org/ Bumblebee project wiki]

* [https://github.com/Bumblebee-Project/bbswitch Bumblebee project bbswitch repository]

Join bumblebee devs at #bumblebee at freenode.net.

Show more