SDB:NVIDIA SUSE Prime

Jump to: navigation, search


Tested on openSUSE

Recommended articles

Icon-manual.png

SUSE Prime is a tool used for switching between integrated Intel GPU and NVIDIA GPU on Optimus laptops. It is alternative to Bumblebee.

With SUSE Prime setup, all applications render either on Intel or on NVIDIA. You can switch between them using a prime-select tool. Log-out and log-in is required for the change to take effect.

Icon-warning.png
Warning: SUSE Prime is a setup for X server. In general, it does not work with Wayland. For using it with Wayland, consider using the offloading approach

Situation

You have Optimus laptop and want ability to switch between NVIDIA and Intel GPUs.


Procedure

  • Install the NVIDIA proprietary driver: SDB:NVIDIA drivers
  • Make sure you have no /etc/X11/xorg.conf file and no configuration files with "ServerLayout", "Device" or "Screen" sections in the /etc/X11/xorg.conf.d directory. (Clean installation fulfills that.)
  • Install the suse-prime and bbswitch-kmp-default packages.

Usage

To switch between Intel and NVIDIA, run as root:

# prime-select boot nvidia

or

# prime-select boot intel

or

# prime-select boot offload

The latest is recommended as it provides the ability to use the GPU for specific applications (see Offloading).

Then log out and log in to apply the changes.

Please note: if you have an Optimus laptop, there are additional steps required to make sure the Nvidia card is powered off. A systemd service needs to be installed.

Please see https://github.com/openSUSE/SUSEPrime

Verification

To verify which GPU is in use, you can compare the output of following commands (remember to use prime-run if using the offloading approach):

Intel

# xrandr --listproviders
    Providers: number : 1
    Provider 0: ... associated providers: 0; name: modesetting
# glxinfo | grep 'OpenGL renderer string'
    OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile

NVIDIA

# xrandr --listproviders
    Providers: number : 2
    Provider 0: ... associated providers: 1; name: NVIDIA-0
    Provider 1: ... associated providers: 1; name: Intel
# glxinfo | grep 'OpenGL renderer string'
    OpenGL renderer string: GeForce GT 640M LE/PCIe/SSE2

Offloading

With recent drivers, you can use the following:

# prime-select boot offload

This allows to use the integrated GPU while offloading specific computations and renderings to the NVIDIA GPU. In order to define which applications/command should be offloaded to the NVIDIA GPU, you can create a script prime-run:

#!/bin/bash
__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia "$@"

After saving it in a directory in your PATH variable and making it executable with chmod +x prime-run, you can use it like prime-run steam for running steam or any other application using the NVIDIA GPU.

Starting with suse-prime-0.8.15 (available for Tumbleweed) the above prime-run script is included and no longer needs to be created manually.

How does it work?

The prime-select script modifies two things in the system:

  • Switches the X server's GLX extension between the original and NVIDIA implementations.
  • Copies either /usr/share/prime/xorg-nvidia.conf or /usr/share/prime/xorg-intel.conf into the /etc/X11/xorg.conf.d directory.

When the Intel option is selected, the X server is configured to completely ignore the NVIDIA card. The NVIDIA driver will keep it sleeping.

When the NVIDIA option is select, X server will use both cards - NVIDIA for rendering and Intel as output provider. The configuration of output provider is done automatically by the X server on start.

Customizing the configuration

If you need change the "Screen", "Device" or "ServerLayout" sections of X configuration, make you changes in the /usr/share/prime/xorg-nvidia.conf or /usr/share/prime/xorg-intel.conf files.

Any other sections (e.g. input device configurations) can be done in files in the /etc/X11/xorg.conf.d directory.

Troublehooting

Xorg/Wayland

If Nvidia driver not activated on login (if you choose it), you are probably using Wayland Protocol. To verify what X server you're using:

# loginctl 
    SESSION  UID USER   SEAT  TTY
     1 1000 youruser seat0

then

# loginctl show-session 1 | grep Type
    Type=x11

if it's wayland and not x11, you're using Wayland.

To configure system to use X11:

Edit

/etc/gdm/custom.conf

replace

#WaylandEnable=false

with

WaylandEnable=false

Reboot.

Tearing problem

Maybe you'll encounters some tearing problem with Nvidia activated. To get rid of this, you must activate the "PRIME Synchronization".

create the file

/etc/modprobe.d/nvidia-drm-nomodeset.conf 

and insert the line

options nvidia_drm modeset=1 

then use command

# sudo dracut -f

reboot.

Icon-warning.png
Warning: In some configuration, PRIME synchronization not working and X server will not starting, if it happens, restart in recovery, delete the file /etc/modprobe.d/nvidia-drm-nomodeset.conf, use dracut -f then reboot.

Installer freezes on optimus laptops

1. Boot Laptop with openSUSE Tumbleweed live USB/DVD.

2a. If you are installing using UEFI, move down to select "installation", press "e" to edit grub entry called "installation". Find the line that starts with "linuxefi /boot/vmlinuzxxx", move after "splash=silent" and add the following (without brackets) "nomodeset". Press F10 to boot. Note that the installer no longer hangs.

2b. If you are installing using legacy BIOS boot, move down to select "installation", press "F5", move down to select "nomodeset", press enter to confirm. Note below "F5 Kernel" now it shows "nomodeset". Hit enter to begin installation. Note that the installer no longer hangs.

3. Install openSUSE Tumbleweed.

4. Update repos and upgrade system:

$ "sudo zypper ref && sudo zypper dup". 

5. Reboot the system.

6. Remove the nomodeset kernel option.

edit

/etc/default/grub

find the line starting with

"GRUB_CMDLINE_LINUX_DEFAULT="

delete

nomodeset

7. Update grub.

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

8. Proceed with nvidia driver installation per official documentation: https://en.opensuse.org/SDB:NVIDIA_drivers

9. Proceed with suse-prime installation and testing per official documentation: https://en.opensuse.org/SDB:NVIDIA_SUSE_Prime

10. Reboot system