eGPU on Linux - Easy-to-use setup script
I have created a script which automatically detects your (E)GPUs and creates the needed X-Server configuration files.
You won't have to mess around with finding the correct BUS-IDs and convert them from dec to hex or anything like that, the script takes care of it.
Just execute the setup command and choose which GPU is the internal, and which the external one.
After that, your computer will automatically detect on startup wheter your EGPU is connected or not, and decides which X-Server configuration it is going to use.
For further information, please refer to the README in my Github Repository.
You'll also find all the source code in there.
Connect your EGPU to your computer and make sure the Thunderbolt connection is authorized. Then execute the following commands.
$ sudo add-apt-repository ppa:hertg/egpu-switcher $ sudo apt update $ sudo apt install egpu-switcher $ sudo egpu-switcher setup
No more steps needed, your computer will automatically select the correct X-Server configuration on startup.
I am using this script with my Lenovo Thinkpad X1 Extreme (Hybrid graphics with a Nvidia GTX 1050 Ti). My EGPU is a GTX 1080 in a Mantiz MZ-02 VENUS enclosure.
This was only tested in Ubuntu 19.04, but it might work in other distros / versions too.
As i have no AMD GPU, this was only tested with Nvidia, but theoretically AMD GPUs could work too. Would be great if someone could test that and report back if it works. Update: @itsage successfully tested it, and it does work with AMD GPUs as well. There seem to be issues in using 5K+ displays, but those are unlikely to be directly related to the script.
Why yet another script
I was initially quite overwhelmed by the steps i had to take in order to make my EGPU work with Ubuntu. As i had no knowledge about X-Server and why i needed to tamper around with it. I created this project mainly to learn more about X-Server, GPUs in Linux and how to publish packages for Ubuntu.
I am in no means an expert, and there certainly are some bugs, but i've tried my best and hope that someone may find it useful.
If this script doesn't work for you
Please let me know or feel free to create a pull request.
Also, the whole setup process can be reverted by executing egpu-switcher cleanup or by removing the package completely with apt remove --purge egpu-switcher. This command will even restore your previous xorg.conf file, if you had one.
Please also refer to these other great projects if mine doesn't work for you:
Thanks, looking forward to it!
I hope that "amdgpu" is the correct driver name to use in the xorg.conf, cause that's what i currently write into it, if the GPU has "AMD" in its name.
Super-happy to see eGPU on Linux get easier and easier. Wish I had a bare metal Linux machine to experiment + a bunch of time.
@hertg I have great news to report. It worked first try on my Alienware 15 R3! First test was with the Razer Core + WX 9100. I connected a 5K monitor HP Z27q but the drivers couldn't combine the two DisplayPort streams to produce 5K resolutions. Even a single DisplayPort connection didn't work well because instead of going to 4K, it was a vertical half of 5K.
I then tried another eGPU setup [Razer Core X Chroma + Radeon VII]. It worked too and the connected monitor this time was a Samsung 49". It's a single DisplayPort conenction and I got full resolution, 3840 x 1080 at 144Hz. I fired up Steam Play and got Age of Empires II running nicely on the external monitor.
There's a strange cursor jump with the internal display when the AMD eGPU is connected. You may have seen in the first photo, the system couldn't detect the Intel iGPU because the internal display is directly attached to the GTX 1070 dGPU. Perhaps I need to install a different set of Nvidia drivers?
@itsage Great to hear that it (somewhat) works with AMD GPUs.
That's a very strange behaviour indeed. I never tested it with a 4k+ monitor, but it works for me with the monitors below.
Unfortunately, I don't think that i can do much about that issue in my script, since all it does is creating an xorg.conf file with the following contents:
Section "Module" Load "modesetting" EndSection Section "Device" Identifier "Device0" Driver "<your-driver>" BusID "<your-bus-id>" Option "AllowEmptyInitialConfiguration" Option "AllowExternalGpus" "True" EndSection
For the integrated graphics: Did you disable the integrated graphics in the BIOS? Because that is what i had to do, in order to install Ubuntu 19.04. I then re-enabled it later after the installation was complete. If you connected your internal display directly to the dedicated GPU, i think you should still see the integrated graphics, but i might be wrong about that (?).
It's also kind of strange, why your Wireless Network Adapter shows up in the list, would you mind posting the output of the following command: lspci | grep -Ei "3d|vga"
Also try executing the lspci command without grep, and see if your integrated graphics shows up in this list.
Which nvidia drivers do you have installed currently? I am on nvidia-418.
I will post the results of my system below, maybe it helps you in finding a possible issue.
sudo apt list --installed *nvidia*
lspci | grep -Ei "3d|vga"
Looks like the wifi card is on bus 61 which in hex is "3D"
why are you using an nVidia eGPU? Common sense is that AMD is much better supported in Linux, isn't it?
I made a switch from using a desktop to using a notebook + egpu, so the GTX 1080 is the one i had in my desktop previously.
Yes, as far as i know, AMD does publish their drivers open source, therefore it can be better integrated into Linux. I'm still hoping Nvidia might do the same someday.
@hertg Thank you for the advice. I was on nvidia-390. The AMD eGPU is running Mesa 19.0.2 and Nvidia dGPU is running 418 now.
I was also able to replicate this success on a 2019 Razer Blade Stealth. Intel iGPU, MX150 dGPU, and Radeon VII eGPU all showed up. There's some "invalid number" message after I set the GPU preferences but things seem to work fine.