eGPU on Linux - Easy-to-use setup script
In the end I replaced the nVidia 1080 Ti GPU with an AMD Radeon RX580 GPU, and it all fired up and worked smoothly. The compiled version of gnome-egpu works flawlessly, I can change between using internal GPU and eGPU flawlessly - that's with Ubuntu 21.04 and Wayland.
@troozers, Ah, that's good you got it all working. With gnome-egpu do you still have to restart or at least restart your display manager for it to switch? I'll be sure to keep that switcher in mind if I ever switch to gnome. It's probably a good excuse now to install another distro with gnome + wayland alongside Arch and Windows 10.
@raggamuffin, I have so far (switch off between docked and non-docked) as that fits my usage profile - I mainly use this between work and home so usually have the laptop switched off between states.
However I will have a try to see if it will work automagically between internal/external without having to restart. I will keep you updated.
@troozers, Thanks. It looks like the next set of nvidia drivers might work a bit better with Wayland. I’m not getting my hopes up though, considering their general attitude towards linux support, and the articles I’ve read are a bit ambiguous with regards to the specifics of the support. https://www.phoronix.com/scan.php?page=news_item&px=NVIDIA-470-Wayland-Friendly
So just to recap for everyone, here's the state of Linux eGPU solutions right now:
For anyone using an Xorg based desktop (most desktops right now), the scripts egpu-switcher (this thread) or gswitch should work for any Xorg desktop with either NVIDIA or AMD eGPUs. So if you're using a desktop like Cinnamon, XFCE, LXDE, Budgie, Gnome (with nvidia drivers), KDE Plasma's default, or most others, then these scripts will be right for you.
For Wayland based desktop environments, the compositor needs to include a method of setting the eGPU as the primary renderer for the compositor. Since Gnome included this (via this PR) it is possible to set the eGPU as primary through a udev rule and this is what the gnome-egpu script does. Sway's wl-roots also includes this feature and I have a script for doing a similar thing on Sway (and should work for other wl-roots based DEs as well). Hopefully KDE will include this feature in kwin eventually as well.
Wayland and Xorg solutions are mostly mutually exclusive so installing one will typically not affect the other.
I think I have an idea for how to force the eGPU as primary in a generalized way across Wayland DEs (so this should work in KDE Wayland as is without changes to kwin). The idea is to bind the iGPU (+dGPU if you have one and any related audio devices) to pcie-stub at boot so the eGPU is the only GPU for the compositor to use. Then hopefully the iGPU could be released to its normal driver after login. If this pans out I'll try and post a script on github.