Switch Intel and NVIDIA GPUs in Arch Linux
Written on 2019-05-12
There are a lot of laptops nowadays that use both an Intel integrated GPU and a discrete NVIDIA GPU. NVIDIA developed a technology that manages such setups. From the Arch Linx wiki:
NVIDIA Optimus is a technology that allows an Intel integrated GPU and discrete NVIDIA GPU to be built into and accessed by a laptop. Getting Optimus graphics to work on Arch Linux requires a few somewhat complicated steps.
The wiki describes how to take setup OPTIMUS graphics using different methods. I'm going to show you how to toggle the active video card. In a perfect world, we would have dinamically switching for GPUs for both the open-source and the proprietary NVIDIA drivers, but until now, only the nouveau drivers can do this using a technology called PRIME. That's why people like me, who want to use the proprietary drivers to achieve better performance, need to use other methods, such as manual GPU switching.
There is actually a way to run programs using the NVIDIA card with proprietary drivers while anything else is working on the Intel one but it involves using Bumblebee which has no support for Vulkan.
optimus-manager is a program that intends to port the functionality of
prime-select from Ubuntu-based distros. Here's how it works when you switch
from the NVIDIA GPU to the Intel GPU:
- You are automatically logged out from your session, which also stops the X server (warning : this closes all opened applications)
- The Nvidia modules are unloaded and either bbswitch or nouveau are loaded instead. bbswitch is used to turn off the card on machines which do not support power management from the kernel, while nouveau is the open-source driver for Nvidia cards, which allows you to use external outputs even in Intel mode.
- The configuration for X and your login manager is updated (note that the configuration is saved to dedicated files, this will not overwrite any of your own configuration files)
- The login manager restarts a X server running on the proper GPU.
I'm going to cover the installation and usage of
with no display manager, because this is what I use and it seems the hardest
config of them all (but is still pretty simple). Instructions for other configs
are available in the README and on the project's wiki (be sure to check out the FAQ too).
At the time of writing the 1.0 version is not yet released, but you can install it from the AUR:
sudo yay -S optimus-manager-git
If you want the latest stable version, install
exec /usr/bin/prime-offload to your .xinitrc, after
Switch your active GPU with:
where <mode> is either
End your X session to kill the X server (default shortcut is $mod+shift+e).
sudo /usr/bin/prime-switch. This command must be run as root.
Restart your X server with
startx. You should be now using the selected GPU.
You can check which card is running with