Setup & Software Discussions
Ubuntu 19.04 - Easy-to-use setup script for your EGPU
 

Ubuntu 19.04 - Easy-to-use setup script for your EGPU  

  RSS

hertg
(@hertg)
Active Member
Joined: 3 months ago
 

Hello there,

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.

Installation
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

screenshot setup

No more steps needed, your computer will automatically select the correct X-Server configuration on startup.

Disclaimer
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:

This topic was modified 3 months ago

Notebook: Lenovo ThinkPad X1 Extreme (GTX 1050 Max-Q Ti)
EGPU: Mantiz MZ-02 VENUS (GTX 1080)
OS: Ubuntu 19.04


DrEGPU, Madlink, mac_editor and 1 people liked
ReplyQuote
itsage
(@itsage)
Famed Member Admin
Joined: 3 years ago
 

@hertg Welcome aboard and thank you for this simple-to-use script! I will try it on my Alienware 15R3 [Nvidia GTX 1070 dGPU] with an AMD eGPU and report back.

This post was modified 3 months ago

Best ultrabooks for eGPU use

eGPU enclosure buying guide

109 external GPU build guides


ReplyQuote
hertg
(@hertg)
Active Member
Joined: 3 months ago
 

@itsage
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.

Notebook: Lenovo ThinkPad X1 Extreme (GTX 1050 Max-Q Ti)
EGPU: Mantiz MZ-02 VENUS (GTX 1080)
OS: Ubuntu 19.04


ReplyQuote
mac_editor
(@mac_editor)
Noble Member Moderator
Joined: 2 years ago
 

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.

purge-wrangler.shpurge-nvda.shset-eGPU.shautomate-eGPU EFI Installer
----
Troubleshooting eGPUs on macOS
Command Line Swiss Knife
eGPU Hardware Chart
Multiple Build Guides
----
Current: MacBook Pro RP560X + 480/R9 Fury/Vega 64 | GTX 780/1070
Previous: 2014 MacBook Pro 750M + 480/R9 Fury | GTX 780/980 Ti/1070


ReplyQuote
itsage
(@itsage)
Famed Member Admin
Joined: 3 years ago
 

@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?

This post was modified 3 months ago

Best ultrabooks for eGPU use

eGPU enclosure buying guide

109 external GPU build guides


ReplyQuote
hertg
(@hertg)
Active Member
Joined: 3 months ago
 

@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.

screenshot nvidia xconfig

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*

screenshot drivers

lspci | grep -Ei "3d|vga"

screenshot lspci

uname -a

screenshot uname

Notebook: Lenovo ThinkPad X1 Extreme (GTX 1050 Max-Q Ti)
EGPU: Mantiz MZ-02 VENUS (GTX 1080)
OS: Ubuntu 19.04


Madlink and itsage liked
ReplyQuote
nu_ninja
(@nu_ninja)
Estimable Member
Joined: 1 year ago
 

Looks like the wifi card is on bus 61 which in hex is "3D"

Mid-2012 13" Macbook Pro (MacBookPro9,2) TB1 -> RX 460/560 (AKiTiO Node/Thunder2)
+ macOS 10.14+Win10
+ Linux Mint 19.1


hertg liked
ReplyQuote
OliverB
(@oliverb)
Noble Member
Joined: 9 months ago
 

@hertg
why are you using an nVidia eGPU? Common sense is that AMD is much better supported in Linux, isn't it?

2018 15" MBP & 2015 13" MBP connected to RTX2080Ti GTX1080Ti GTX1080 Vega56 RX580 R9-290 GTX680


ReplyQuote
hertg
(@hertg)
Active Member
Joined: 3 months ago
 

@oliverb
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.

Notebook: Lenovo ThinkPad X1 Extreme (GTX 1050 Max-Q Ti)
EGPU: Mantiz MZ-02 VENUS (GTX 1080)
OS: Ubuntu 19.04


OliverB liked
ReplyQuote
itsage
(@itsage)
Famed Member Admin
Joined: 3 years ago
 

@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.

Best ultrabooks for eGPU use

eGPU enclosure buying guide

109 external GPU build guides


ReplyQuote
hertg
(@hertg)
Active Member
Joined: 3 months ago
 

@itsage
Did using the Nvidia 418 driver resolve any of your issues?
Thanks for the feedback, i think there's a bug in my script where i detect if the egpu is connected (It probably doesn't understand the Bus-ID "PCI:10:0:0").
Will try to fix that soon, when i've got time. With that bug, the automatic detection probably won't work on your system.

Notebook: Lenovo ThinkPad X1 Extreme (GTX 1050 Max-Q Ti)
EGPU: Mantiz MZ-02 VENUS (GTX 1080)
OS: Ubuntu 19.04


itsage liked
ReplyQuote
mac_editor
(@mac_editor)
Noble Member Moderator
Joined: 2 years ago
 

@nando4 @itsage At your discretion, perhaps it would be good to link this post under how-to or software for Linux in the top header.

purge-wrangler.shpurge-nvda.shset-eGPU.shautomate-eGPU EFI Installer
----
Troubleshooting eGPUs on macOS
Command Line Swiss Knife
eGPU Hardware Chart
Multiple Build Guides
----
Current: MacBook Pro RP560X + 480/R9 Fury/Vega 64 | GTX 780/1070
Previous: 2014 MacBook Pro 750M + 480/R9 Fury | GTX 780/980 Ti/1070


itsage liked
ReplyQuote
itsage
(@itsage)
Famed Member Admin
Joined: 3 years ago
 
Posted by: mac_editor

@nando4 @itsage At your discretion, perhaps it would be good to link this post under how-to or software for Linux in the top header.

I added this thread to the Top Nav Menu just now.

Best ultrabooks for eGPU use

eGPU enclosure buying guide

109 external GPU build guides


ReplyQuote
OliverB
(@oliverb)
Noble Member
Joined: 9 months ago
 
Posted by: itsage
Posted by: mac_editor

@nando4 @itsage At your discretion, perhaps it would be good to link this post under how-to or software for Linux in the top header.

I added this thread to the Top Nav Menu just now.

This is great! Thank you.

Perhaps, if we do some changes, I would suggest to alter this guide at little. For me it looks a little bit too complicated and meanwhile outdated. This may be just my opinion. Perhaps somebody else shares this opinion, too? @mac_editor?

2018 15" MBP & 2015 13" MBP connected to RTX2080Ti GTX1080Ti GTX1080 Vega56 RX580 R9-290 GTX680


ReplyQuote
hertg
(@hertg)
Active Member
Joined: 3 months ago
 

Update
I just released version 0.9.0, you can update with the following command.

sudo apt update
sudo apt --only-upgrade install egpu-switcher

I fixed the issue where EGPUs on double digit PCI-Lanes weren't detected properly.
Also added a little 5s delay for the detection on startup. I realized that the script somehow ran before the EGPU could even connect to the computer, i hope that doesn't happen anymore.

Notebook: Lenovo ThinkPad X1 Extreme (GTX 1050 Max-Q Ti)
EGPU: Mantiz MZ-02 VENUS (GTX 1080)
OS: Ubuntu 19.04


DrEGPU, OliverB and itsage liked
ReplyQuote
OliverB
(@oliverb)
Noble Member
Joined: 9 months ago

ReplyQuote
rstrube
(@rstrube)
Active Member
Joined: 9 months ago
 

This is really fantastic, thank you!

I've taken some of the other scripts that have been posted here and modified them with some extra features.  One thing that I found really useful was affecting the /usr/share/vulkan/icd.d files (used by vulkan applications).

My problem is that I have a Dell XPS 9575.  This system has an Intel iGPU, a dedicated AMD GPU (Vega M) and then when I have my eGPU enabled (Nvidia RTX 2070) I have the following files in that directory:

  • nvidia_icd.json
  • intel_icd.i686.json
  • radeon_icd.i686.json
  • intel_icd.x86_64.json
  • radeon_icd.x86_64.json

And many vulkan applications (think games running via DXVK) don't allow you to manually select which vulkan icd to use.  Lutris now has this feature, but for those of you that want to guarantee that a specific GPU is used, the best approach is to move the other files to another temporary directory.  In my case I move them to a directory called /usr/share/vulkan/icd.d/egpu-helper-backup

If I don't do this most applications tend to pic the AMD GPU (which is discrete, but certainly not as fast as my eGPU).

I've integrated this into this script: https://gitlab.com/rstrube/linux_mercury/blob/master/supporting/egpu-helper/egpu-helper

You can see that if the user passes in 'egpu' as a parameter, in addition to doing the xorg symlinking, it also will move any Intel and AMD icd files to a backup directory (and any nivida icd files from the backup directory and back to the main icd.d directory).

Perhaps you could integrate this into the script? I think the complicated part is that the files you move will vary based on an indiviuals setup.  For me I move Intel and AMD icd files when running my eGPU, but for others this might not be the case. In your case you have two nividia GPUs (the laptop's discrete and the eGPU one), so you would need to keep the icd file for nvidia and just move the Intel one (I believe, although I'm not sure?).

I'd also be happy to try to come up with a nice solution and open a PR.

Let me know your thoughts!

Edit: One other thing I was curious about, when the eGPU is not connected, you're specifically use an xorg.conf.internal file that would use (for example) the "intel" driver, and modsetting for the other GPUs (if you picked the Intel iGPU as your INTERNAL GPU).  I believe it's now recommended to just use modesetting for Intel iGPUs.  See this except from the Arch wiki:

https://wiki.archlinux.org/index.php/Intel_graphics

Note: Some (Debian & UbuntuFedoraKDE) recommend not installing the xf86-video-intel driver, and instead falling back on the modesetting driver for fourth generation and newer GPUs. See [1][2]Xorg#Installation, and modesetting(4). However, the modesetting driver can cause problems such as Chromium Issue 370022. Also, the modesetting driver will not be benefited by Intel GuC/HuC/DMC firmware.

Perhaps the best course of action would just be to not have any xorg.conf in the event that the user does not have their eGPU connected and let Xorg figure things out?

This post was modified 3 months ago

Pending: Add my system information and expected eGPU configuration to my signature to give context to my posts


itsage liked
ReplyQuote
(@madlink)
New Member
Joined: 3 months ago
 

I'm using an Aorus Gaming Box with a GTX 1080 on a Razer stealth  and this worked beautifully.
thank you so much

Pending: Add my system information and expected eGPU configuration to my signature to give context to my posts


ReplyQuote
hertg
(@hertg)
Active Member
Joined: 3 months ago
 

@rstrube
That sounds really interesting, altough i do not have any experience with vulkan whatsoever. 

I would be happy to integrate this, but i need to know if this is a really specific setup you have, or if there are other people with the same kind of setup and use-case.
It's important to me that i can keep the script as generic as possible and most importantly that it stays as simple as possible.

That being said, if we can define how the script detects if the user has a vulkan setup (maybe ask him in the setup process),
and define a generic naming-convention for the files (maybe by adding the bus-id to the filename?) it might really be a useful extension.

Is the setup you have, with the *.json files for your different GPUs, a standard type of setup or did you come up with that?
Does vulkan automatically select a json file from /usr/share/vulkan/icd.d/, no matter what its name is?

Regarding the modesetting config, good point.
As you may have seen, I'm using the same xorg.conf template for the external and the internal GPU, and just replace the driver and bus-id.
Did i understand correctly, that it is recommended for the Intel integrated graphics to not having specified the driver at all, and instead just use the modesetting driver?

Your suggestion to not create an xorg.conf.internal file could be a good idea.
But there may be people that want to add custom xorg configurations when running on the internal GPU, therefore we still need some kind of xorg.conf.internal.
Perhaps we could leave the xorg.conf.internal file empty, if the user selects the Intel integrated graphics as internal GPU.
What are your thoughts about that?

You seem to be well informed about the topic, so thanks alot for the input!

Notebook: Lenovo ThinkPad X1 Extreme (GTX 1050 Max-Q Ti)
EGPU: Mantiz MZ-02 VENUS (GTX 1080)
OS: Ubuntu 19.04


ReplyQuote
sandblau
(@sandblau)
New Member
Joined: 3 months ago
 

Thank you so much. Its working great with a Dell XPS 9370, Razor Core X and a Nvidia 1080. External or internal Display ist working. Thank you, amazing work.

Pending: Add my system information and expected eGPU configuration to my signature to give context to my posts


ReplyQuote
(@jeff_blakely)
New Member
Joined: 3 months ago
 

How do you get the 'internal' display to work in addition to the 'external' displays connected to the eGPU?  Right now I can get either the internal to work with the discrete GPU or the externals to work with the eGPU but not all 3.

Notebook: Razer 15" 2019 RTX 1070 Max-Q
EGPU: Razer Core V2 (GTX 1070 Ti)
OS: Ubuntu 19.04


ReplyQuote
hertg
(@hertg)
Active Member
Joined: 3 months ago
 

@jeff_blakely
Thanks for the report, i have also recognized this issue recently.
But in my case, my internal screen sometimes works and sometimes doesn't...
I've tried to narrow down the cause of this problem in the last 2 hours, but without any luck.

As i was tracking down the problem, i realized that on the login-screen all my monitors worked and after login the internal stopped working.
I also somehow managed to invert the problem, that the external monitors stopped working after login instead of the internal one.

My current workaround is that i switched from using gdm3 to using lightdm.
It seems that all my monitors are working right now, on login and after login.
(see: https://askubuntu.com/a/1049669/952594 )

Would be great if anyone with more experience in this topic could have a short look at it.

I'm sorry, if i couldn't help you.

This post was modified 2 months ago

Notebook: Lenovo ThinkPad X1 Extreme (GTX 1050 Max-Q Ti)
EGPU: Mantiz MZ-02 VENUS (GTX 1080)
OS: Ubuntu 19.04


itsage liked
ReplyQuote
nu_ninja
(@nu_ninja)
Estimable Member
Joined: 1 year ago
 

Most display managers run 1 session for both the login screen and the desktop, but I think gdm3 is unique in that it uses 2 different sessions, one for the login screen and one for the desktop with both running at the same time when you're logged in. Combined with gdm3 using wayland by default(?) I think this makes things difficult when using scripts like this to change the x server so I'd recommend sticking with a DM like lightdm to make things easiest.

To get all your monitors to work I usually just have to mess around with xrandr until everything shows up since you guys have nvidia dgpus it might take more trickery to get those working. If you do find an xrandr configuration that works and want it to load automatically check out autorandr

Mid-2012 13" Macbook Pro (MacBookPro9,2) TB1 -> RX 460/560 (AKiTiO Node/Thunder2)
+ macOS 10.14+Win10
+ Linux Mint 19.1


ReplyQuote
h4wk590
(@h4wk590)
Active Member
Joined: 4 weeks ago
 

Looking forward to trying this when my GPU comes in. 🙂

Laptop: Lenovo Thinkpad T480s(i5 8250u, 24gb RAM) eGPU: Akitio Node (MSI RX580 8GB)This setup is pending..


ReplyQuote
(@joe_veronese)
New Member
Joined: 10 months ago
 

Question. I used this on my Lenovo Yoga 730 13". It works great when an external display is also connected, however, when I am just using the internal screen mouse clicks and typing lag horribly. Plug the external display in and the lag disappears immediately. Any trouble shooting advice?

Pending: Add my system information and expected eGPU configuration to my signature to give context to my posts


ReplyQuote
nu_ninja
(@nu_ninja)
Estimable Member
Joined: 1 year ago
 

I believe in your case you'll want to select the internal gpu mode, then follow the steps for enabling prime, which are well summarized here.

Mid-2012 13" Macbook Pro (MacBookPro9,2) TB1 -> RX 460/560 (AKiTiO Node/Thunder2)
+ macOS 10.14+Win10
+ Linux Mint 19.1


ReplyQuote
hertg
(@hertg)
Active Member
Joined: 3 months ago
 

@joe_veronese

I don't know if you are having the exact same issues, but maybe the following can help you.

I've had similar issues with unbearable input lag and sudden crashes of the USB ports from my Mantiz Venus.
My mouse would disconnect after a few seconds and my keyboard would sometimes press the sammmmmmmmmmmmme key for several seconds.
The same symptoms were described in the Arch Linux wiki on the Dell TB16 article.

Going to the BIOS and change Thunderbolt Security from "User Authorization" to "No Security" has fixed that problem for me.
Now my peripherals are all working properly.

Please note:
If you handle very sensitive data on your computer, this may not be an option.
For more information on the possible vulnerability see http://thunderclap.io/
But to be better protected against that, you would have to have enabled at least "Secure Connect" and locked your UEFI/BIOS with a strong password in the first place.

Notebook: Lenovo ThinkPad X1 Extreme (GTX 1050 Max-Q Ti)
EGPU: Mantiz MZ-02 VENUS (GTX 1080)
OS: Ubuntu 19.04


ReplyQuote