Our notebooks usually have a battery-saving iGPU and a powerful but also power-hungry dGPU. You can now run the entire system on one or the other GPU, depending on what you need. However, you have to restart the PC to switch.
Alternatively, the desktop environment and other programs that don't need much graphics performance are calculated on the iGPU and the dGPU is only activated for the individual games and programs that need it. This technology is called
OPTIMUS under Windows and
PRIME GPU Render Offloading or
GPU on-demand mode under Linux.
Validity
This is a short tutorial on how to use PRIME. The sections "Preparation (TUXEDO OS/Ubuntu(-derivative))" and "Start menu and desktop shortcuts (TUXEDO OS/Ubuntu(-derivative) WebFAI with KDE-Plasma)" refer explicitly to TUXEDO OS and / or WebFAI installations. All other explanations in this manual apply to all Linux distributions, including those not based on Ubuntu.
Prerequisites
This guide only applies if the proprietary NVIDIA driver 470.xx or newer or an open-source driver (amdgpu (AMD/Radeon), Nouveau (NVIDIA), i915 (Intel)) is used as a prerequisite. It explicitly does not work if the proprietary Nvidia driver 390.xx or older or the old open source "radeon" driver is/was used. This means that a NVIDIA GeForce 800M or newer or an AMD Radeon R9 or newer as dGPU is required.
Preparation (TUXEDO OS/Ubuntu(-derivative))
1. activate the
PRIME/on-demand mode with
sudo prime-select on-demand
2. install
tuxedo-dgpu-run with
sudo apt install tuxedo-dgpu-run
3. restart the PC.
Now the desktop environment runs on the iGPU, but the dGPU can be activated for individual programs at any time.
Command Line
For TUXEDO_OS/Ubuntu(-derivatives) WebFAI: Run the command by typing the following
dgpu-run «code to be run»
For other distributions: The dGPU is used if the environment variables
__NV_PRIME_RENDER_OFFLOAD=1,
__VK_LAYER_NV_optimus=NVIDIA_only,
__GLX_VENDOR_LIBRARY_NAME=nvidia and
DRI_PRIME=1 are set with the following command:
__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia DRI_PRIME=1 «code to be run»
A brief explanation of what these variables do:
- __NV_PRIME_RENDER_OFFLOAD=1
- Vulkan: Enable the implicit overlay for offloading to NVIDIA (which reorders the available GPUs so that the NVIDIA dGPUs come first)
- OpenGL: Make NVIDIA's implementation check if it is running on a PRIME device (and prevent it from crashing in this case)
- __VK_LAYER_NV_optimus=NVIDIA_only
- Vulkan: make the implicit overlay for offloading to NVIDIA remove all non NVIDIA GPUs from the availability list (optional)
- __GLX_VENDOR_LIBRARY_NAME=nvidia
- OpenGL: Use NVIDIA's OpenGL implementation (i.e. use the proprietary NVIDIA driver and not Mesa, which only supports the open source drivers, e.g. i915, AMDGPU and Nouveau)
- DRI_PRIME=1
- For PRIME devices with discrete AMD GPU or if Nouveau is used, this variable should be sufficient. The other three variables are ignored if the proprietary NVIDIA driver is not installed.
Start Menu and Desktop Shortcuts (TUXEDO_OS/Ubuntu(-derivative) WebFAI with KDE-Plasma)
Right click on a program shortcut
Start application with discrete GPU/Run application with discrete GPU. However, this may not work for shortcuts created by different launchers. Here either the launcher itself must be started on the dGPU, or it must be set in the launcher itself, which programs are to be executed with the dGPU. Here is a guide for all known launchers supported on Linux.
Steam
1. Open the properties of the game/program.
2. In the
Launch Options field in the
General tab, add the following:
__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only
__GLX_VENDOR_LIBRARY_NAME=nvidia DRI_PRIME=1 %command%
Please ensure that this is at the beginning of the line if there is already another entry there.
Lutris
1. In Lutris, select
Configure for the game/program.
2. Check the
Enable NVIDIA Prime Render Offload option in the
System Preferences/System options tab.
3. Click on
Save
Heroic
1. Open the
Settings of the game
Add the following to the
Advanced Options (Environment Variables) field in the
Other tab:
__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only
__GLX_VENDOR_LIBRARY_NAME=nvidia DRI_PRIME=1
Bottles
1. Select the bottle that contains the game/program.
2. Select
Change launch options for the game/program.
3. Insert the following in the input field:
__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only
__GLX_VENDOR_LIBRARY_NAME=nvidia DRI_PRIME=1 %command%
Please ensure that this is at the beginning of the line if there is already another entry there.
4. Click on
Save
Minigalaxy
Menu items/shortcuts created by Minigalaxy, unlike shortcuts created by other launchers, work using the method described in the "Start Menu and Desktop Shortcuts" section. So please do not launch games/programs installed via Minigalaxy from the launcher interface, but create a shortcut and run it on the dGPU as described above. For Minigalaxy to create menu items/shortcuts, follow these instructions before installing a game:
1. From the hamburger menu, select
Preferences.
2. Activate
Create menu shortcuts.
3. Click on
Save.
4. Install the desired game.
PlayOnLinux
Shortcuts created by PlayOnLinux, unlike shortcuts created by other launchers, work using the method described in the "Start Menu and Desktop Shortcuts" section. So please do not launch games/programs installed by PlayOnLinux via the launcher interface, but create a shortcut and run it on the dGPU as described above.
Rare
Rare does not currently allow you to set individual environment variables per game (but the feature will come in one of the next versions).
To use the dGPU anyway:
1. if Rare is started: quit Rare completely (including the icon in the system section/system tray in the system tray).
2. start Rare on the dGPU (see the section "Command line" or "Start menu and desktop shortcuts").
3. start the game.
4. exit Rare completely after finishing the game. Otherwise, the dGPU will remain on and continue to consume power.
GameHub
GameHub currently does not allow to set individual launch options easily per game (the feature has already been worked on, possibly it will come in one of the next versions).
To use the dGPU anyway:
1. if GameHub is started: quit GameHub completely.
2. start GameHub on the dGPU (see "Command line" or "Start menu and desktop shortcuts")
3. start the game
4. quit GameHub completely after finishing the game. Otherwise, the dGPU will remain on and continue to consume power.
itch
itch does not currently allow you to set individual startup options per game.
To use the dGPU anyway:
1. if itch is started: quit itch completely (Including the icon in the system section/system tray in the system tray).
2. start itch on the dGPU (see "Command line" or "Start menu and desktop shortcuts")
3. start the game
4. quit itch completely after finishing the game. Otherwise, the dGPU will remain on and continue to consume power.
Pegasus Frontend
Pegasus Frontend unfortunately does not currently allow you to set individual launch options per game.To still use the dGPU on games it launches directly:
1. when Pegasus Frontend is started: quit Pegasus Frontend.
2. start the Pegasus Frontend on the dGPU (see "Command Line" or "Start Menu and Desktop Shortcuts")
3. start the game
4. quit the Pegasus frontend again after finishing the game. Otherwise the dGPU will stay on and continue to consume power.
If the Pegasus frontend does not start the game directly but e.g., via Steam, please read the explanation about Steam above.
Windows Launcher via Wine (Epic Games Store, Origin, Ubisoft Connect, etc.)
We advise against using the Windows Launcher via wine directly because of the better alternatives in the form of Lutris and Heroic. Even in Lutris, for example, the Epic Games Store should not be installed and used directly, but the games individually. In this case, Lutris installs the Epic Games Store, if needed, in the background itself and the games remain cleanly separated from each other so that Lutris can apply an individual wine configuration per game.
If you still want to use a Windows launcher directly and enable PRIME, the procedure is the same as for the other launchers that don't allow individual launch options per game (itch, Pegasus Frontend). This is due to the principle that these options have to be set before wine is launched.