A script to change Xorg config
For many users, eGPU is less than plug and play. In my case, I already have two internal GPU's, and have to fiddle with Xorg configs some way or another, and it's a pick and choose. You can have the onboard (either the integrated or the discrete) GPU render the laptop screen and have the eGPU render an external screen, or you can have the eGPU render both, or something else of your choosing, but not dynamically, sadly.
The way I've solved it is to have an Xorg config that makes the eGPU render both the laptop screen and any external screen(s) that may be connected and when I want to use the eGPU, I have:
And then create a symbolic link to /etc/X11/xorg.conf, plug in the eGPU, reload and done. But after a while, the manual steps started to bore me and remembered the old saying: "One time is none. Two times is a script!"
And then I got a "little" carried away and wanted to learn how to write QT GUI applications Thing is, I can´t learn just by reading the documentation and look at examples, I have to have "a mission" to set out on and this was the perfect task to get me going!
And then I wanted to make the installation process even easier for new users, so I invested some time to learn how to make .deb packages out of the binaries:
So you can clone, edit and then build these packages yourselves! I have setup a PPA for this to make the process as easy as humanly possible!
Here's how to set it up in Ubuntu:
$ sudo add-apt-repository ppa:karli.sjoberg/gswitch-ppa $ sudo apt-get update $ sudo apt-get install -y gswitch-gui
Or if you're running openSUSE:
$ sudo zypper addrepo https://download.opensuse.org/repositories/home:Sebulon/openSUSE_Tumbleweed/home:Sebulon.repo $ sudo zypper refresh $ sudo zypper install gswitch
Just replace the version with whatever you're running. If something's missing or not quite right, give me shout and I'll make sure to fix it!
Then you run the friendly setup routine:
$ sudo gswitch setup
After that you´re all set! When you want to use the eGPU, you just run:
$ sudo gswitch egpu
The laptop will reload the screen, so make sure to save everything open before doing so! And when you´re done, you run:
$ sudo gswitch internal
It will reload and you can disconnect the eGPU.
Or if you´d rather want to use the GUI, open your applications menu and look under System 😉
This package also comes with automatic detection of eGPU at boot!
After gswitch has been configured and you've got the switching set up, simply run 'systemctl enable gswitch' and it will configure the eGPU automatically when you boot. It will also switch back to internal if you've by accident forgotten to before leaving and found yourself stuck at a black screen; no more!
Yeah, that happened once too many
Hope it helps!
PS. If you have something you feel could be done better, we can discuss the changes here, then for the actual code, pull requests are warmly welcome!
@sebulon Welcome aboard and thank you for sharing this script! To clarify we only need to change the driver identification and BusID to replicate your success? I'm using an Alienware 15 R3 that has Intel iGPU running the internal display, nVidia dGPU that doesn't seem to do anything, and AMD eGPU that can work with internal display mode (DRI_PRIME=1) but has absolutely no external monitor output.
Thanks man, appreciate it!
Well, I can't say for sure, no guarantees. It's Hippie, right? 🙂 But in theory, yeah, should be.
Prime is something new to me, could you explain how to use it?
I'm a novice so I simply followed the instructions posted in this Linux sub forum. To get my AW15R3 use the eGPU I put Prime string in front of whichever software I want to run. For example, I run Unigine Valley with
DRI_PRIME=1 ./valley. This works well so far but I'd like to get external monitor output and have a better control over which GPU is doing what.
Ah, OK, seems easy enough 🙂
Going to try it that tonight and see how it goes. Wonder how that goes with processes that starts other processes... Like you start steam; that gets rendered with the eGPU, but what about when I start a game from it, does it inherit, or does it default? I'll report back when it's tested!
And about the "BusID", remember to convert from hex to decimal. Maybe you already knew that but it's worth mentioning
Neh, Prime did not work for me, it renders on the built-in Quadro in my Lenovo P50, looks like this:
$ lspci | grep VGA 00:02.0 VGA compatible controller: Intel Corporation HD Graphics 530 (rev 06) 01:00.0 VGA compatible controller: NVIDIA Corporation GM107GLM [Quadro M1000M] (rev a2) 0a:00.0 VGA compatible controller: NVIDIA Corporation GP106 [GeForce GTX 1060 6GB] (rev a1) $ xrandr --listproviders Providers: number : 2 Provider 0: id: 0x29a cap: 0x1, Source Output crtcs: 4 outputs: 6 associated providers: 1 name:NVIDIA-0 Provider 1: id: 0x43 cap: 0x6, Sink Output, Source Offload crtcs: 3 outputs: 1 associated providers: 1 name:modesetting $ DRI_PRIME=1 glxinfo | grep "OpenGL renderer" OpenGL renderer string: Quadro M1000M/PCIe/SSE2 $ DRI_PRIME=0 glxinfo | grep "OpenGL renderer" OpenGL renderer string: Quadro M1000M/PCIe/SSE2
So I guess the time spent scripting pays off, at least Could you run the commands and share the output, just for comparisons sake?
Thank you for testing it with your setup. I will get the output and post them tonight on my AW15R3 + eGPU.
Here's my output:
$ lspci | grep VGA 01:00.0 VGA compatible controller: NVIDIA Corporation GP104BM [GeForce GTX 1070 Mobile] (rev a1) 09:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Vega 10 XT [Radeon PRO WX 9100] $ xrandr --listproviders Providers: number : 0 $ DRI_PRIME=1 glxinfo | grep "OpenGL renderer" OpenGL renderer string: Radeon(TM) Pro WX9100 (VEGA10, DRM 3.26.0, 4.18.17-300.fc29.x86_64, LLVM 7.0.0) $ DRI_PRIME=0 glxinfo | grep "OpenGL renderer" OpenGL renderer string: NV134
Seeing that output, I think your problem is that the WX cards are (to the best of my knowledge) only supported by the AMDGPU-PRO driver and not the open source amdgpu driver. And to make things even more confusing, note that you might not be able to install the AMDGPU-PRO driver on your existing OS, only Ubuntu 16.04.
You could try going with a different card, maybe an nvidia one since @sebulon seems to have gotten nvidia eGPU+dGPU working.
Looks supported to me: