-
Notifications
You must be signed in to change notification settings - Fork 12
Home
For Linux-based systems, Wayland has become more and more popular as a replacement for the X (Xorg) display server. Most recently, the transition of Ubuntu 21.04 to a Wayland-based GNOME desktop by default has made the most news, however many other distros and desktops exist using a Wayland protocol either optionally or by default. This includes desktops such as KDE Plasma, Weston and Sway.
Due to the nature of the Wayland compositor, there is not yet any universal way (as least as far as I know) to specify the primary GPU renderer for the compositor. This seems to be left to the specific way the compositor is implemented. Thus, GNOME's mutter may have a different process compared to Sway's wl-roots or KDE's KWin, etc. Up until this point, this left 1 of 2 options. Either the compositor could implement a specific way to control the primary renderer, or the user could use DRI_PRIME to offload rendering to a secondary GPU. Neither of these are optimal. The first requires specific work from the project developing the compositor and their specific method of control may not be the same as for other compositors. The second method of using DRI_PRIME (or similar offloading techniques) results in significantly reduced performance for eGPUs due to unnecessary transfer of display data across the eGPU's bandwidth-limited connection. The purpose of this script is to use a universal system that works across all compositors and also enables maximum possible eGPU performance. Note that this script is not designed to replace existing solutions such as gswitch or egpu-switcher. If you have an Xorg based desktop, these solutions are still the best option and should be preferred over this script.
Method 1 of this script works by requesting that the user disables their iGPU graphics device(s) at boot. This leaves the compositor no other choice except to use the eGPU when booting. This may seem like an extreme solution and it is in some ways, however, as this script was designed for portability across desktops and distros, this solution makes for the most universal solution. Note that there is also an option to re-enable the iGPU device after login or if no other GPU is found (if the eGPU is not plugged in or not working).
In order to disable the iGPU graphics, their PCI Bus IDs and drivers are stored in /usr/share/all-ways-egpu/user-bus-ids
, which is then used by the script to unbind the virtual terminals, drivers and finally PCIe device addresses.
Methods 2 and 3 work by requesting that the user enters the Bus IDs of the eGPU and tries to set a variety of variables that the Wayland compositor may use to set that GPU as primary. These methods may work on Sway's wlroots, KDE Plasma's Kwin or GNOME's mutter compositors.
- Linux-based OS with graphical, Wayland-based desktop.
- You have already authorized your EGPU (if necessary) and are able to connect to it.
- You have at least pciutils 3.3.x or higher installed (check with
lspci --version
).
- You have already installed the latest drivers for your GPUs.
- You have at least Bash 4.x or higher installed. (I have tried to keep the script POSIX compatible, but bash is recommended as this is what I have tested with.)
-
Systemd or OpenRC (as of version 0.30) are used for triggering the script at certain times on boot and login. If you do not have systemd for whatever reason, OpenRC style calls and init scripts are used. Other init systems are not supported at this time.
- Note: the OpenRC calls currently assume the display manager is started with an init script called "display-manager". On some distros, xdm or a script with some other name is used. In these cases, I recommend linking that script with the following command:
ln -s /etc/init.d/xdm /etc/init.d/display-manager
- Note: the OpenRC calls currently assume the display manager is started with an init script called "display-manager". On some distros, xdm or a script with some other name is used. In these cases, I recommend linking that script with the following command:
Thanks to both the eGPU and VFIO communities for being so welcoming and helpful. Countless hours were spent consulting others in those communities more experienced than myself in order to put together this script.
Questions or comments on this script can be directed to myself through issues on this Github repo or posts on eGPU.io tagging @nu_ninja