From Fedora Project Wiki

Description

Nvidia Optimus is an optimization technology created by Nvidia which, depending on the resource load generated by client software applications, will transparently and seamlessly switch between two graphics adapters within a computer system in order to provide either maximum performance or minimum power draw from the system's graphics rendering hardware. From Bumblebee's FAQ: Bumblebee is a 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.

Install Dependencies

#yum install -y libbsd-devel libbsd glibc-devel libX11-devel help2man autoconf git tar glib2 glib2-devel kernel-devel kernel-headers automake gcc gtk2-devel

You also need to install VirtualGL. Download the latest version for your arch at the VirtualGL download page or use yum command

#yum install VirtualGL 

If you want to run 32 bit apps on your 64 bit system, then also install:

#yum install VirtualGL.i686 

Install Bumblebee

Install the Bumblebee yum repository

Fedora 18

#yum -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee/fedora18/noarch/bumblebee-release-1.1-1.noarch.rpm

Fedora 19

#yum -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee/fedora19/noarch/bumblebee-release-1.1-1.noarch.rpm

Fedora 20

#yum -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee/fedora20/noarch/bumblebee-release-1.1-1.noarch.rpm

Install Bumblebee:

#yum -y install bbswitch bumblebee

Bumblebee with the NVIDIA proprietary drivers

The previous commands install bumbleblee with the nouveau drivers. If you want to install bumblebee with the NVIDIA proprietary drivers you must also follow these instructions:

Install the bumblebee-nonfree repository:

Fedora 18

#yum -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee-nonfree/fedora18/noarch/bumblebee-nonfree-release-1.1-1.noarch.rpm

Fedora 19

#yum -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee-nonfree/fedora19/noarch/bumblebee-nonfree-release-1.1-1.noarch.rpm

Fedora 20

#yum -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee-nonfree/fedora20/noarch/bumblebee-nonfree-release-1.1-1.noarch.rpm

For all versions

Make sure you have glibc-devel installed because it is needed for bumblebee-nvidia to compile the driver

sudo yum install glibc-devel

Now install bumblebee-nvidia

#yum -y install bumblebee-nvidia

"bumblebee-nvidia" is both a rpm package and a shell script. The "bumblebee-nvidia" package contains the shell "wrapper" script, init scripts to run it at bootup, and a SELinux security policy, and lastly a copy of the NVidia Linux binary driver "blob" downloaded from NVidia's UNIX drivers page. This is why the packages are so large compared to the bumblebee package.

Reboot.

Testing Bumblebee

If you want to make sure you have bumblebee up and running, write:

optirun glxgears -info

You should see some gears rotating, and in the terminal you should see "GL_VENDOR = NVIDIA Corporation" or something similar.

Primus

For speed imrovements you can use primus. Primus is a shared library that provides OpenGL and GLX APIs and implements low-overhead local-only client-side OpenGL offloading via GLX forking, similar to VirtualGL. It intercepts GLX calls and redirects GL rendering to a secondary X display, presumably driven by a faster GPU. On swapping buffers, rendered contents are read back using a PBO and copied onto the drawable it was supposed to be rendered on in the first place. Currently primus requires the NVIDIA proprietary drivers.

Install primus:

yum install primus 

If you want to run 32 bit apps on your 64 bit system, then also install:

yum install primus.i686

Testing primus

Open up a terminal and run:

PRIMUS_VERBOSE=2 optirun -b primus glxgears -info

If primus is working properly, you should see "primus: profiling:" messages every so often in the terminal you ran it from.

How to use Bumblebee

General Usage:

optirun [options] <application> [application-parameters]

If you installed primus, then you can use the following command to take advantage of it:

optirun -b primus <application> [application-parameters]

Start Windows applications:

optirun wine <windows application>.exe

with primus:

optirun -b primus wine <windows application>.exe

By default, primus renders up to 60 fps. To render more frames per second:

vblank_mode=0 optirun -b primus <application> [application-parameters]

In practice this will probably only waste power, as most screens do not display more than 60 frames per second.

You can always run "man optirun" for more information.

Troubleshooting

Most of the stuff that are present here are suggested by bumblebee maintainer Gary Gatling.

Unable to load GPU driver error with optirun

The verbose output of optirun provided by appending the switch -vv can give us an idea of the issue at hand.

[user1@localhost ~]$optirun -vv vlc
[   52.410461] [DEBUG]Reading file: /etc/bumblebee/bumblebee.conf
[   52.411039] [INFO]Configured driver: nvidia
[   52.411659] [DEBUG]optirun version 3.2.1 starting...
[   52.411716] [DEBUG]Active configuration:
[   52.411745] [DEBUG] bumblebeed config file: /etc/bumblebee/bumblebee.conf
[   52.411765] [DEBUG] X display: :8
[   52.411785] [DEBUG] LD_LIBRARY_PATH: /usr/lib64/nvidia-bumblebee:/usr/lib/nvidia-bumblebee:/usr/lib64:/usr/lib
[   52.411805] [DEBUG] Socket path: /var/run/bumblebee.socket
[   52.411826] [DEBUG] Accel/display bridge: auto
[   52.411847] [DEBUG] VGL Compression: proxy
[   52.411868] [DEBUG] VGLrun extra options:
[   52.411886] [DEBUG] Primus LD Path: /usr/lib/primus:/usr/lib64/primus
[   52.411939] [DEBUG]Using auto-detected bridge virtualgl
[   52.434739] [INFO]Response: No - error: Could not load GPU driver

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

[   52.434763] [DEBUG]Socket closed.
[   52.434781] [ERROR]Aborting because fallback start is disabled.
[   52.434787] [DEBUG]Killing all remaining processes.

When you upgrade from one version of nvidia binary to higher version of the module, sometimes the un-install phase is not complete and in that case this following suggestion should help.

1. First unload the nvidia module by logging in as root in a terminal. Terminal output of cat /proc/apci/bbswitch should be OFF after this step.

systemctl restart bumblebeed 

2. Uninstall the nvidia module

/usr/sbin/bumblebee-nvidia --debug --uninstall

3. modinfo nvidia probably gives you an output similar to this

[root@localhost ~]# modinfo nvidia
filename:       /lib/modules/3.11.8-300.fc20.x86_64/kernel/drivers/video/nvidia.ko
modinfo: ERROR: could not get modinfo from 'nvidia': No such file or directory

4. Prepare to compile the nvidia driver at restart for the current kernel and reboot the system

[root@localhost ~]# touch /etc/sysconfig/nvidia/compile-nvidia-driver
[root@localhost ~]# reboot

5. Post reboot should give the modinfo output something similar to this and you should be able to use optirun as intended.

@localhost ~]$ modinfo nvidia
filename:       /lib/modules/3.11.8-300.fc20.x86_64/kernel/drivers/video/nvidia.ko
alias:          char-major-195-*
version:        331.20
supported:      external
license:        NVIDIA
alias:          pci:v000010DEd00000E00sv*sd*bc04sc80i00*
alias:          pci:v000010DEd00000AA3sv*sd*bc0Bsc40i00*
alias:          pci:v000010DEd*sv*sd*bc03sc02i00*
alias:          pci:v000010DEd*sv*sd*bc03sc00i00*
depends:        drm,i2c-core
vermagic:       3.11.8-300.fc20.x86_64 SMP mod_unload 
parm:           NVreg_Mobile:int
parm:           NVreg_ResmanDebugLevel:int
parm:           NVreg_RmLogonRC:int
parm:           NVreg_ModifyDeviceFiles:int
parm:           NVreg_DeviceFileUID:int
parm:           NVreg_DeviceFileGID:int
parm:           NVreg_DeviceFileMode:int
parm:           NVreg_RemapLimit:int
parm:           NVreg_UpdateMemoryTypes:int
parm:           NVreg_InitializeSystemMemoryAllocations:int
parm:           NVreg_RMEdgeIntrCheck:int
parm:           NVreg_UsePageAttributeTable:int
parm:           NVreg_MapRegistersEarly:int
parm:           NVreg_RegisterForACPIEvents:int
parm:           NVreg_CheckPCIConfigSpace:int
parm:           NVreg_EnablePCIeGen3:int
parm:           NVreg_EnableMSI:int
parm:           NVreg_MemoryPoolSize:int
parm:           NVreg_RegistryDwords:charp
parm:           NVreg_RmMsg:charp.
parm:           NVreg_AssignGpus:charp

Make sure your nvidia module is unloaded when you do this steps. For some repeating the steps a couple of times was necessary.

Useful links