I’m posting this because recently someone (in the openSUSE Chinese forums) asked for help on how to switch graphics cards using switcherooctl
.
I realized that the wiki doesn’t document the use of environment variables to switch the graphics card, except for suse-prime and openSUSE’s current recommendation of switcherooctl
. This method is actually documented in the archlinux wiki, and it works for Wayland as well.
I documented it on the openSUSE Chinese wiki two years ago, but then I forgot about it until someone asked for help recently.
- Original link: SDB:NVIDIA PRIME Render Offload - openSUSE Wiki
Install the graphics driver
See SDB:NVIDIA Drivers for details.
Check the software version
- Use Plasma 5.20.2 or higher.
- Make sure the NVIDIA closed-source driver version is not less than 495.44.
- Make sure the Qt version is higher than Qt5.15.0
- Make sure the Nvidia EGL library is installed, its package name in the openSUSE software repository is
libnvidia-egl-wayland11
.
To use Plasma Wayland sessions with hardware acceleration on XWayland applications, you need to make sure your system has installed:
- Xorg 1.20.12 and higher;
- XWayland 21.1.2 and higher;
- libxcb 1.1.7 and higher.
The above conditions are generally met automatically for Tumbleweed users.
Remove suse-prime
suse-prime only works under X11, and it will affect the following operations.
sudo zypper rm -u suse-prime
If you have installed additional modules based on SDB:NVIDIA_SUSE_Prime, please uninstall them as well:
sudo zypper rm bbswitch-kmp-default
Then reboot the system.
Using the modesetting driver
Use the following command to check if the driver is running in modesettings mode:
sudo cat /sys/module/nvidia_drm/parameters/modeset
The terminal output should be “Y”.
If not, open YaST, find and open Boot Loader → Kernel Parameters (K), fill in nvidia-drm.modeset=1
in Optional Kernel Command Line Parameters (P), save the settings and exit YaST.
Then reboot the system.
Login
Select Plasma (wayland) on the KDE login screen and enter the desktop.
prime-run
According to the official documentation, to let the program call NVIDIA graphics card, you can use the following command:
__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia [command]
You can write this command as a shell script named prime-run
and put it in $PATH
:
#!/bin/bash
__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia "$@"
Then use this command to run the application:
prime-run [application name, command or script]
Others
To see which applications are using xwayland, you can install xlsclients
:
sudo zypper in xlsclients
Then run xlsclients
directly to list the programs currently using xwayland.
NVIDIA Optimus
For more information on various NVIDIA Optimus options, see NVIDIA Optimus - archlinux wiki.
Envycontrol
EnvyControl is a CLI tool for easy GPU switching on Nvidia Optimus laptops under Linux.
There is currently an experimental package on OBS, which can be used, or installed manually:
Clone the repository (for example, clone to ~/bin
or ~/.local/bin
):
cd ~/bin && git clone https://github.com/bayasdev/envycontrol.git
Then write in the ~/.bashrc
file:
alias envycontrol="python3 $HOME/bin/envycontrol/envycontrol.py"
Reload the bash shell configuration
source ~/.bashrc
Use EnvyControl to set the graphics mode to Hybrid:
sudo envycontrol -s hybrid --rtd3
After the settings are completed, reboot the system.
For other details, see the project readme file.