Alternate script for eGPU (automated detection @ boot, configure X)  

  RSS

(@tara_fitzgerald)
Active Member
Joined: 1 month ago
Posts: 6
February 12, 2019 2:41 am  

Hi, folks,

Thought I'd share the config/setup that I'm using for my eGPU automatic detection at boot, and change of xorg.conf files before starting the DM. Hopefully somebody will find it useful.

Why I did it: Because I can. But also because I don't like sebulon's script for a few reasons - I don't run a debian-based distro, and while it's possible to install a .deb on my distro of choice it can be problematic especially as it comes to dependencies. As I'm on a rolling release distro especially, a PPA is impossible and installing a .deb that doesn't change leaves the possibility of it getting broken by a future update. I also don't even have qt installed, so his gui is a non-starter, and don't really like having to manually change the configuration. This way, if I want to use the eGPU, I just plug it in & reboot - it'll detect the presence of the eGPU on boot and configure X accordingly. That said, if you are using his script, the /usr/bin/egpu script can be tweaked to use his script instead of manually changing the configuration.

The how:
There's 3 scripts that you need to create/install on your system, and a service you need to create/enable.
/usr/bin/egpu:    https://pastebin.com/tdXQzzCU
/etc/systemd/system/egpu.conf:   https://pastebin.com/swxKCAyR
/etc/X11/xorg.conf.d/disabled/21-egpu.conf:  https://pastebin.com/UxaTf0Dn   (you'll likely have to create the disabled subfolder)

That's it, that's all. You'll need to tweak the 21-egpu.conf for your specific system/configuration, but otherwise you should be good to go. Just enable the egpu service, and it'll detect on boot & configure xorg appropriately.

To enable the service:

sudo systemctl enable egpu

As for how to tweak the 21-egpu.conf file, you need to make sure it has the right drivers for your GPU, and the right BusID, in decimal form. If you type

lspci | grep VGA

it'll give you a list of your video cards & their identifiers. Such as:

00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (rev 07)

In this case, as you can see from my 21-egpu.conf file, the Intel (modesetting) graphics driver is PCI:0:2:0. To get the BusID, change any hexadecimal numbers into decimal, and replace the dot with a colon.

It's important to set your integrated graphics to modesetting if you're using displays that are plugged into it (such as on a laptop) - otherwise some applications can render using the wrong GPU, even if you're launching using DRI_PRIME=1. In my case, for example, I have an XFX RX580 GTS Black Edition OC+ 8GB video card in a Razer Core X eGPU enclosure. On a 2560x1080 panel I was getting 7-10fps on the Unigine Heaven (medium) benchmark before I set modesetting. After setting it, I got framerates in the range you'd expect them to be - 40+fps on ultra. (the card's capable of better in a desktop configuration, but an eGPU on Thunderbolt3 only has 4 PCIe lanes). By setting modesetting, you'll use the integrated graphics as a canvas that the eGPU can draw to.

One last configuration that's entirely optional, but is harmless, is to add a line to your ~/.profile

export DRI_PRIME=1

This setting is 100% optional. It'll save you having to specifically edit the launchers for applications you want to run using PRIME, but at the expense of having everything (including your desktop environment) render using the eGPU. For me, that's not a problem - if I am booting up with the eGPU connected in the first place, it's because I intend to use it. Somewhat counterintuitively, the frame rates I saw in Heaven actually improved slightly when I made this change but your mileage may vary. The environment variable will be ignored if there is only one GPU connected.

Hope somebody finds this useful. 🙂 It's possible to use on a system that's using System V or upstart instead of systemd, but I didn't see the need as most distros are going with systemd these days. If you need help getting it running on one of the other systems, just ask 🙂

System: Tuxedo InfinityBook Pro 13", i5-8250u, 16GB RAM, 1TB NVMe
eGPU: Razer Core X, 8GB XFX RX580 GTS Black Edition OC+
OS: Arch Linux


ReplyQuote
nu_ninja
(@nu_ninja)
Estimable Member
Joined: 11 months ago
Posts: 121
February 12, 2019 3:30 am  

Nice, systemctl is a better tool than what I was originally using. FYI, I wrote a more complicated script I posted here for figuring out if the eGPU is attached. Instead of just counting the number (which could be thrown off by a dGPU laptop) it tries to find a match for the BusID from the config file. You should be able to just change the file path and if/else contents.

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


ReplyQuote
(@tara_fitzgerald)
Active Member
Joined: 1 month ago
Posts: 6
February 12, 2019 1:29 pm  

Thank you 🙂

You could just change the expected count to 3 for the eGPU check script if you're in a laptop that has a dGPU, iGPU, and eGPU. I'll be honest, it hadn't even occurred to me that you might be in a situation where you're using an eGPU to offload from a system that already has a dGPU. If you need a different xorg.conf file for the 2-gpu vs. 3-gpu configuration, the same egpu script can be tweaked as well.

I can provide instructions for how to do that, if folks need. The short version is create a 2nd xorg conf file for the no-eGPU configuration, and have it swap the conf files instead of copying or deleting the conf.

System: Tuxedo InfinityBook Pro 13", i5-8250u, 16GB RAM, 1TB NVMe
eGPU: Razer Core X, 8GB XFX RX580 GTS Black Edition OC+
OS: Arch Linux


ReplyQuote
(@michael_watkins)
New Member
Joined: 4 days ago
Posts: 2
February 17, 2019 3:14 pm  

I am struggling with this. I'm newer to Linux at a lot of this. My issue is that I have no xorg in X11. Would it be possible to get a full tutorial on start to finish from install of Ubuntu to getting external monitors working. Also when your doing all of this do you the have thunderbolt 3 cable plugged in? If not at what point do you plug it in. For me every time I try to save x configuration it fails. Says I have no xorg server or something like that .

This post was modified 3 days ago

Pending: 2018 Razer Blade 15 / Razer Core v2 my signature to give context to my posts


ReplyQuote
nu_ninja
(@nu_ninja)
Estimable Member
Joined: 11 months ago
Posts: 121
February 17, 2019 7:12 pm  

See my build guide in my signature. If you want to use them, the scripts from this thread would replace steps 3 and 4. You can leave the eGPU plugged in the whole time.

Edit: Also note these steps are only for X11, not wayland. If at the login screen, clicking the gear icon shows "Ubuntu on Wayland" selected, then that would be the problem.

This post was modified 3 days ago

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


ReplyQuote