SDB:NVIDIA Bumblebee
This Support Data Base (SDB) entry points to a possible procedure for installing the NVIDIA proprietary driver together with Bumblebee/bbswitch on recent versions of openSUSE.
Situation
You have an Optimus laptop with an NVIDIA discrete graphics adapter. You may need to run programs using the discrete graphics adapter, but you don't want the discrete graphics active all the time, because that would cause the laptop to consume too much energy. Or you simply want to disable the discrete graphics adapter completely on an Optimus laptop such as the Dell Latitude E6430, whose BIOS does not offer a way to do that.
Procedure
If you need the old instruction with X11:Bumblebee repository, it's here: https://en.opensuse.org/index.php?title=SDB:NVIDIA_Bumblebee&oldid=118653
Preparation
Though generally reliable, unexpected problems can occur after finishing this installation and configuration procedure. As of openSUSE 13.2 btrfs is the default filesystem for root partition. If you have brtfs as your filesystem you should take a snapshot of your filesystem so you have a simple recovery point in case of something going wrong.
sudo snapper create -d BeforeBB
As of 7 january 2018 (kernel 4.4.104-39), there are issues apparently impacting Intel Skylake laptop. If your laptop make use of this architecture and you install bumblebee without taking some precautions, you will end up with a hard lock when X11 starts : black screen and computer not responding at all. Be warned that Snapper rollback is not helpful in this case and that your are good for a full reinstallation if you end up in this situation[*]. See the related Bumblebee bug report to get a workaround for your specific case and a link to the related Linux kernel bug report. The workaround can easily be applied by going to Yast2 > System > Boot Loader > Kernel Parameters, append the right "acpi_osi" value(s) at the end of the field named "Optional Kernel Command Line Parameter". Save, reboot and you can proceed with following procedure.
[*]actually IME, there is a chance of recovery if you blow it & find yourself here: At bootloader screen, press 'e' to edit current selection boot params, find the line that boots the os (the line where you'd add nomodeset or similar boot options, which didn't help btw), erase the part that says 'resume=/swap/path/or/whatever' if present, & append " 3" (a space, then # 3) to that line. Then press F10 to boot the edited config. You should be able to get into Ctrl+Alt+F2 terminal after giving your disk encryption password (if you use one). From there 'sudo snapper list' -> pick which # looks okay, let's say rollback #12, so you'd issue: 'sudo snapper rollback 12' then 'sudo shutdown -r now' and quite likely save yourself an hour of re installing time, plus the headache of reinstalling your favourite programs & configs.
Install bumblebee
Installing bumblebee is pretty straightforward:
sudo zypper in bumblebee bbswitch
Add yourself to the bumblebee group (here "username" should be replaced with your real username):
sudo usermod -aG bumblebee username
Add yourself to the video group (here "username" should be replaced with your real username):
sudo usermod -aG video username
Then enable and start bumblebee:
sudo systemctl enable bumblebeed sudo systemctl start bumblebeed
Blacklist nouveau (even if you plan to use nouveau driver):
echo "blacklist nouveau" | sudo tee -a /etc/modprobe.d/99-local.conf sudo dracut -f --regenerate-all
If you plan to use 32bit apps (like steam), install required libraries:
sudo zypper in Mesa-libGL1-32bit libX11-6-32bit primus-32bit
OPTIONAL: Install NVIDIA driver
If you want to use the advanced features of the secondary Nvidia graphics card, you can install the proprietary Nvidia driver as follows:
Leap releases
Make sure all lines in /etc/ld.so.conf.d/nvidia-gfxG*.conf are commented out. The nvidia installer should detect optimus hardware and do it automatically, but it's better to be safe.
#/usr/X11R6/lib64 #/usr/X11R6/lib
If they are not, then edit the file to make it as above, and run
sudo ldconfig
Add the nvidia module to blacklist:
echo "blacklist nvidia" | sudo tee -a /etc/modprobe.d/99-local.conf sudo mkinitrd
Setup xorg module directory:
sudo mkdir -p /usr/lib64/nvidia/xorg/modules/extensions sudo ln -s /usr/lib64/xorg/modules/extensions/nvidia/nvidia-libglx.so /usr/lib64/nvidia/xorg/modules/extensions/libglx.so
Configure bumblebee: Edit /etc/bumblebee/bumblebee.conf as root and set the following (lines that are not mentioned here, should be left unchanged, not deleted):
[bumblebeed] TurnCardOffAtExit=true Driver=nvidia [driver-nvidia] LibraryPath=/usr/X11R6/lib64:/usr/X11R6/lib XorgModulePath=/usr/lib64/nvidia/xorg/modules,/usr/lib64/xorg/modules
Add bumblebee repository for Leap 42.3 if using Leap 42.3:
sudo zypper addrepo https://download.opensuse.org/repositories/X11:Bumblebee/openSUSE_Leap_42.3/X11:Bumblebee.repo
Add bumblebee repository for Leap 15 if using Leap 15:
sudo zypper addrepo https://download.opensuse.org/repositories/X11:Bumblebee/openSUSE_Leap_15.0/X11:Bumblebee.repo
Install the driver:
sudo zypper in nvidia-bumblebee nvidia-bumblebee-32bit sudo systemctl enable dkms
Update the kernel image:
sudo mkinitrd
Tumbleweed
Add bumblebee repository:
sudo zypper addrepo https://download.opensuse.org/repositories/X11:Bumblebee/openSUSE_Tumbleweed/X11:Bumblebee.repo
Install the driver:
sudo zypper in nvidia-bumblebee nvidia-bumblebee-32bit sudo systemctl enable dkms
Update the kernel image:
dracut -f --regenerate-all
Additional steps for Leap 15.0
Packages supplied by NVidia for openSUSE Leap 15.0 do not contain any files or symlinks in the /etc/X11R6/ directory, so you are to create them by yourself. Do the following:
Create the required directories:
mkdir -p /usr/X11R6/lib64/ mkdir -p /usr/X11R6/lib/
And create the symlinks inside them:
cd /usr/X11R6/lib64/ ln -s /usr/lib64/libEGL_nvidia.so.0 libEGL_nvidia.so.0 ln -s /usr/lib64/libGL.so.1.0.0 libGL.so ln -s /usr/lib64/libGL.so.1.0.0 libGL.so.1 ln -s /usr/lib64/libGL.so.1.0.0 libGL.so.1.0.0 ln -s /usr/lib64/libGLESv1_CM_nvidia.so.1 libGLESv1_CM.so ln -s /usr/lib64/libGLESv1_CM_nvidia.so.1 libGLESv1_CM.so.1 ln -s /usr/lib64/libGLESv1_CM_nvidia.so.1 libGLESv1_CM_nvidia.so.1 ln -s /usr/lib64/libGLESv2_nvidia.so.2 libGLESv2.so ln -s /usr/lib64/libGLESv2_nvidia.so.2 libGLESv2.so.2 ln -s /usr/lib64/libGLESv2_nvidia.so.2 libGLESv2_nvidia.so.2 ln -s libGLX.so.0.0.0 libGLX.so ln -s libGLX.so.0.0.0 libGLX.so.0 ln -s /usr/lib64/libGLX_nvidia.so.0 libGLX.so.0.0.0 ln -s /usr/lib64/libGLX_nvidia.so.0 libGLX_nvidia.so.0 ln -s /usr/lib64/libnvidia-cfg.so.1 libnvidia-cfg.so.1 ln -s /usr/lib64/libnvidia-egl-wayland.so.1 libnvidia-egl-wayland.so.1 ln -s /usr/lib64/libnvidia-encode.so.1 libnvidia-encode.so.1 ln -s /usr/lib64/libnvidia-fbc.so.1 libnvidia-fbc.so.1 ln -s /usr/lib64/libnvidia-ifr.so.1 libnvidia-ifr.so.1 ln -s /usr/lib64/libnvidia-ml.so libnvidia-ml.so ln -s /usr/lib64/libnvidia-ml.so.1 libnvidia-ml.so.1 ln -s /usr/lib64/libnvidia-opencl.so.1 libnvidia-opencl.so.1 ln -s /usr/lib64/libnvidia-ptxjitcompiler.so.1 libnvidia-ptxjitcompiler.so.1 ln -s /usr/lib64/libnvidia-wfb.so.1 libnvidia-wfb.so.1 ln -s /usr/lib64/libvdpau_nvidia.so libvdpau_nvidia.so
Defenitely, you can choose which libraries to link or not. The list of them can be displayed via:
ls -n /usr/lib64/|egrep 'nvidia|libGL|libEGL'
If you are going to use multilib, do also:
cd /usr/X11R6/lib/ ln -s /usr/lib/libEGL_nvidia.so.0 libEGL_nvidia.so.0 ln -s /usr/lib/libGL.so.1.0.0 libGL.so ln -s /usr/lib/libGL.so.1.0.0 libGL.so.1 ln -s /usr/lib/libGL.so.1.0.0 libGL.so.1.0.0 ln -s /usr/lib/libGLESv1_CM_nvidia.so.1 libGLESv1_CM.so ln -s /usr/lib/libGLESv1_CM_nvidia.so.1 libGLESv1_CM.so.1 ln -s /usr/lib/libGLESv1_CM_nvidia.so.1 libGLESv1_CM_nvidia.so.1 ln -s /usr/lib/libGLESv2_nvidia.so.2 libGLESv2.so ln -s /usr/lib/libGLESv2_nvidia.so.2 libGLESv2.so.2 ln -s /usr/lib/libGLESv2_nvidia.so.2 libGLESv2_nvidia.so.2 ln -s libGLX.so.0.0.0 libGLX.so ln -s libGLX.so.0.0.0 libGLX.so.0 ln -s /usr/lib/libGLX_nvidia.so.0 libGLX.so.0.0.0 ln -s /usr/lib/libGLX_nvidia.so.0 libGLX_nvidia.so.0 ln -s /usr/lib/libnvidia-cfg.so.1 libnvidia-cfg.so.1 ln -s /usr/lib/libnvidia-egl-wayland.so.1 libnvidia-egl-wayland.so.1 ln -s /usr/lib/libnvidia-encode.so.1 libnvidia-encode.so.1 ln -s /usr/lib/libnvidia-fbc.so.1 libnvidia-fbc.so.1 ln -s /usr/lib/libnvidia-ifr.so.1 libnvidia-ifr.so.1 ln -s /usr/lib/libnvidia-ml.so libnvidia-ml.so ln -s /usr/lib/libnvidia-ml.so.1 libnvidia-ml.so.1 ln -s /usr/lib/libnvidia-opencl.so.1 libnvidia-opencl.so.1 ln -s /usr/lib/libnvidia-ptxjitcompiler.so.1 libnvidia-ptxjitcompiler.so.1 ln -s /usr/lib/libnvidia-wfb.so.1 libnvidia-wfb.so.1 ln -s /usr/lib/libvdpau_nvidia.so libvdpau_nvidia.so
Verify installation
After installation of the software above, reboot your machine.
Check bumblebee is working by opening a terminal and typing:
optirun --status
If you see the message:
Bumblebee status: Ready (3.2.1). X inactive. Discrete video card is off.
Then bumblebee should be working properly. To use the discrete video card, you must launch the program from the terminal:
optirun program-name
You can test this by running:
optirun glxgears -info
(Note: glxgears is in Mesa-demo-x package)
If you see the gears, then your discrete card is working with bumblebee. You'll find something in the terminal like this:
GL_RENDERER GeForce 840M/PCIe/SSE2 GL_VERSION 4.6.0 NVIDIA 418.56 GL_VENDOR NVIDIA Corporation
You may also verify your installation by running nvidia-settings program, which is installed along with the proprietary nvidia drivers:
optirun -b none nvidia-settings -c :8
If you can not get your graphical system back, you should perform a rollback using snapper. If your system does not have btrfs, this does not apply to you. First find out what the number for your snapshot was that you should have made earlier:
sudo snapper list
Then perform the rollback, here "xx" should be replaced by the number of your preparatory snapshot:
sudo snapper rollback xx
Reboot the machine.
FAQ
Problems with GT600M/GT700M series cards (Kepler)
If you cannot load GPU drivers - while bbswitch being loaded - and get an error like this on a Kepler card:
[INFO]Response: No - error: Could not load GPU driver [ERROR]Cannot access secondary GPU - error: Could not load GPU driver
Try changing value of 'load_state' in "/etc/modprobe.d/50-bbswitch.conf" from 0 to -1
echo "options bbswitch load_state=-1 unload_state=1" > /etc/modprobe.d/50-bbswitch.conf
More info on github: bbswitch - scroll to Module options.
Switch State of card Manually with bbswitch
check the state of your card:
cat /proc/acpi/bbswitch
to turn your card off, type:
sudo tee /proc/acpi/bbswitch <<<OFF
Optirun does not run
If you run `journalctl -u bumblebee` and you see
Failed to initialize the GLX module; please check in your X log file that the GLX module has been loaded in your X server, and that the module is the NVIDIA GLX module. If you continue to encounter problems, Please try reinstalling the NVIDIA driver.
You probably installed the non-optimus version nvidia driver, please install from X11:Bumblebee repo (read this wiki page carefully)
Check it by:
sudo update-alternatives --display libglx.so
If you see something like this:
libglx.so - auto mode link best version is /usr/lib64/xorg/modules/extensions/nvidia/nvidia-libglx.so link currently points to /usr/lib64/xorg/modules/extensions/nvidia/nvidia-libglx.so link libglx.so is /usr/lib64/xorg/modules/extensions/libglx.so /usr/lib64/xorg/modules/extensions/nvidia/nvidia-libglx.so - priority 100 /usr/lib64/xorg/modules/extensions/xorg/xorg-libglx.so - priority 50
You installed the non-optimus version nvidia driver, uninstall them and remove the nvidia repo, read "OPTIONAL: Install NVIDIA driver" again.
Optirun return "Cannot access secondary GPU"
If when you run "optirun --status" or "optirun glxgears", it's returned an error like
[ERROR]Cannot access secondary GPU - error: Could not enable discrete graphics card
It could be due to the presence of one or more power management application (e.g. TLP, powertop). After you disable them, optirun should work.
Add the GPU into the TLP blacklist
If you have TLP, you can add the GPU to its blacklist and make optirun works. Find the GPU address
sudo lspci
A row like this should be present, copy the first numbers (e.g. 01:00.0)
01:00.0 VGA compatible controller: NVIDIA Corporation ... [GeForce ...] (rev a1)
Open the TLP configuration file located in /etc/default/tlp
Search the row with "RUNTIME_PM_BLACKLIST", remove the "#" and paste your GPU address. E.G.:
RUNTIME_PM_BLACKLIST="01:00.0"
If other values are present, just add a space after the last number and paste your address.
Search the row with "RUNTIME_PM_DRIVER_BLACKLIST", remove the "#". It should be:
RUNTIME_PM_DRIVER_BLACKLIST="amdgpu nouveau nvidia radeon"
Save and close the file. After a restart, optirun should work.
Disable TLP (only if the previous step has not resolved)
You can disable TLP by typing these commands into the console
sudo systemctl disable tlp sudo systemctl stop tlp
After a restart, optirun should work.
Disable powertop
You can disable powertop by typing these commands into the console
sudo systemctl disable powertop sudo systemctl stop powertop
After a restart, optirun should work.
Tips & tricks
Running Steam
You can run Steam like so:
optirun steam
This will keep your discrete card turned on all the time steam is running.
You can also launch steam as usual and for each game: Right click on the selected game -> Properties -> Set Launch Options. It the window type:
optirun %command%
This will keep your discrete card turned on only for running the game.
Optirun vs Primusrun
Don't use primusrun anymore. Optirun is everything you need.
In the old times optirun was a wrapper script for setting up VirtualGL bridge. Then primus library appeared with it's own primusrun wrapper script. Now optirun is a program integrated with bumblebee daemon and supports both VirtualGL and primus bridges.
Switching between Nouveau and Nvidia driver
Change the line in /etc/bumblebee/bumblebee.conf:
[bumblebeed] Driver=<driver you want to use>
Restart bumblebeed:
sudo systemctl restart bumblebeed
Multi Monitor
It may be the case that some of your outputs are attached to your Nvidia card and some are attached to the Intel card. In which case the outputs attached to your Nvidia card may not work. You can use these outputs with a tool named intel-virtual-output. It comes from the package "xf86-video-intel". Before using it edit /etc/bumblebee/xorg.conf.nvidia change the lines UseEDID "false" and Option "AutoAddDevices" "false" to "true", if you are having trouble with device resolution detection. Commenting out the line Option "UseDisplayDevice" "none" also may help. You should be able to start it in the foreground with intel-virtual-output -f and your outputs should start working.
For more information check the multi monitor page on the Bumblebee wiki.
References
Further information and problem solving: ultimate tutorial installing Bumblebee driver for SUSE
The blog entries below reference a no longer used repository, but they may be useful for information purposes.
For openSUSE 13.1, refer to this blog entry: openSUSE 13.1: install 'bumblebee' and disable discrete graphics adapter on NVIDIA Optimus laptop
For openSUSE 12.3, refer to this blog entry: openSUSE 12.3: How to install 'bumblebee' for NVIDIA Optimus VGA.
For openSUSE 12.2, refer to this blog entry: openSUSE 12.2: How to install 'bumblebee' for NVIDIA Optimus VGA