Giter Club home page Giter Club logo

egpu-switcher's Introduction

egpu-switcher

Distribution agnostic eGPU script that works with NVIDIA and AMD cards.

License Information

Description

The goal of this CLI is to lower the barrier for Linux users to use their eGPU on the Linux Desktop. With the egpu-switcher config command the user can choose their external GPU. On every bootup the service will check if the eGPU is connected and if so, make X.Org prefer it.


Limitations

  • No hotplugging is possible. Users still need to reboot their computer to connect / disconnect the eGPU.

Requirements

  • Running X.Org
  • Thunderbolt connection to eGPU is authorized
  • Necessary graphics drivers for eGPU are installed

Installation

Ubuntu (apt)

The PPA is no longer maintained for now (see #90)

Arch (aur)

paru -S egpu-switcher

🌳⚡ Save time and energy by using the pre-compiled egpu-switcher-bin package

Manual

Installation and setup

Download binary from latest release

Copy binary to /opt, apply proper permissions, and link it in /usr/bin

sudo cp <downloaded-binary> /opt/egpu-switcher
sudo chmod 755 /opt/egpu-switcher
sudo ln -s /opt/egpu-switcher /usr/bin/egpu-switcher
sudo egpu-switcher enable

Uninstall

sudo egpu-switcher disable --hard
sudo rm /usr/bin/egpu-switcher
sudo rm /opt/egpu-switcher

Build

Prerequisites

Install the go toolchain

Installation and setup

git clone [email protected]:hertg/egpu-switcher.git
cd egpu-switcher
make build -s
sudo make install -s
sudo egpu-switcher enable

Uninstall

sudo egpu-switcher disable --hard
sudo make uninstall -s

Commands

Usage:
  egpu-switcher [command]

Available Commands:
  config      Choose your external GPU
  disable     Disable egpu-switcher from running at startup
  enable      Enable egpu-switcher to run at startup
  help        Help about any command
  switch      Check if eGPU is present and configure X.org accordingly
  version     Print version information

Flags:
  -h, --help      help for egpu-switcher
  -v, --verbose   verbose output

Use "egpu-switcher [command] --help" for more information about a command.


Configuration

The config file is created automatically and can be found at /etc/egpu-switcher/config.yaml. Below you can see an example of a configuration file, annotated with additional information.

egpu:
    # the 'driver' and 'id' configs are generated by 'egpu-switcher config'.
    # you probably shouldn't change this manually unless you understand why.
    driver: amdgpu
    id: 1153611719250962689
    
    # OPTIONAL: do not load 'modesetting' in the egpu config
    nomodesetting: false

# OPTIONAL: how many times 'egpu-switcher switch auto' should retry finding the egpu.
# this can be helpful if the egpu takes some time to connect on your machine,
# the following values are the default.
detection:
  retries: 6
  interval: 500 # milliseconds

# OPTIONAL: if you want to execute a script after switching to egpu/internal.
# the values must be absolute paths to a shell script, this script will
# then be run with '/bin/sh $script'.
# 
# it is required that the script is owned by root (uid 0) 
# and has a permission of -rwx------ (0700).
hooks:
  internal: /home/michael/tmp/internal.sh
  egpu: /home/michael/tmp/egpu.sh

Troubleshooting

If you run into problems, please have a look at TROUBLESHOOT.md before reporting any issues.

egpu-switcher's People

Contributors

dependabot[bot] avatar ewagner12 avatar fennifith avatar hertg avatar maddocker avatar marcolaux avatar tbabej avatar toumorokoshi avatar xabolcs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

egpu-switcher's Issues

Steam refuses to load when switching back to "internal"

Context:

I have a clean install of Ubuntu 20.04 on my Lenovo ThinkPad T480, with Intel UHD Graphics 620 and the latest UEFI updates.

I have an Akitio Node eGPU chassis with a Sapphire Radeon R9 Nano GPU.

I have an Iiyama G-Master GB2488HSU monitor connected to the laptop via HDMI and the eGPU via DisplayPort.

I installed steam using "sudo apt install -y steam-installer", logged in, and installed a number of games, before I setup and used egpu-switcher. Since setting up egpu-switcher I have run a couple of games using the eGPU.

Problem:

When I run "sudo egpu-switcher switch internal", restart the computer, and then login again, I am no longer able to run steam.

It runs the process to check for updates, but when it comes to loading the app itself, it looks like it changes the screen's mode setting, and then fails.

Evidence:

myuser@mycomputer:~$ steam
Running Steam on ubuntu 20.04 64-bit
STEAM_RUNTIME is enabled automatically
Pins up-to-date!
Steam client's requirements are satisfied
/home/myuser/.steam/debian-installation/ubuntu12_32/steam -nominidumps -nobreakpad
[2020-05-28 09:55:17] Startup - updater built May 15 2020 03:04:07
[2020-05-28 09:55:17] Verifying installation...
[2020-05-28 09:55:17] Verification complete
STEAM_RUNTIME_HEAVY: ./steam-runtime-heavy
Warning: failed to set thread priority: set failed for 4: -1: setpriority() failed
Warning: failed to set thread priority: set failed for priority 4
Warning: support for elevated priorities is most likely unavailable, suppressing future warnings

Need to reboot twice each time for switching gpu

Hi, thanks for this awesome little program :)
I get this weird issue where each time I either disconnect or connect the eGPU I need to go through not only a shutdown but also a reboot.
I suspect this is an issue with lightdm as the egpu.service is running probably after the display-manager.service, so the startup is stuck, since it uses the old xorg.conf. In support of this, if I drop to a tty, kill lightdm and startx, I get to the DE.
I'm not sure about how to fix it and will be gratful for help.
Thanks,
Lior

External display black despite recognised eGPU using Ubuntu 18.04

TL;DR All drivers are installed and eGPU is recognised by ubuntu 18.04, but I have no display output on the external monitor plugged into the eGPU, nor can I see a second screen in my settings.

I have a Razer Blade Stealth 2016 and I use with a Razer Core V2. I'm running a dual boot and under Windows everything works. However, when booting into Ubuntu 18.04 everything works (after a lot fiddling) except the display output :(

So I can see me nVidia card when using nvidia-smi:

Tue Apr 21 13:20:31 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 435.21       Driver Version: 435.21       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 970     Off  | 00000000:07:00.0 Off |                  N/A |
| 35%   30C    P8    17W / 151W |      0MiB /  4043MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

I tried using the eGPU switch tool but with no change in the behaviour. I can, however, use my external keyboard and mouse which are connected to the Razer Core, which is kind of strange. So I assume that thunderbolt in principle works.

My lspci provide me with the following output:

00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers (rev 02)
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 620 (rev 02)
00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller (rev 21)
00:14.2 Signal processing controller: Intel Corporation Sunrise Point-LP Thermal subsystem (rev 21)
00:15.0 Signal processing controller: Intel Corporation Sunrise Point-LP Serial IO I2C Controller #0 (rev 21)
00:15.1 Signal processing controller: Intel Corporation Sunrise Point-LP Serial IO I2C Controller #1 (rev 21)
00:16.0 Communication controller: Intel Corporation Sunrise Point-LP CSME HECI #1 (rev 21)
00:1c.0 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #3 (rev f1)
00:1c.4 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #5 (rev f1)
00:1d.0 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #9 (rev f1)
00:1f.0 ISA bridge: Intel Corporation Sunrise Point-LP LPC Controller (rev 21)
00:1f.2 Memory controller: Intel Corporation Sunrise Point-LP PMC (rev 21)
00:1f.3 Audio device: Intel Corporation Sunrise Point-LP HD Audio (rev 21)
00:1f.4 SMBus: Intel Corporation Sunrise Point-LP SMBus (rev 21)
01:00.0 Network controller: Qualcomm Atheros QCA6174 802.11ac Wireless Network Adapter (rev 32)
02:00.0 PCI bridge: Intel Corporation JHL6340 Thunderbolt 3 Bridge (C step) [Alpine Ridge 2C 2016] (rev 02)
03:00.0 PCI bridge: Intel Corporation JHL6340 Thunderbolt 3 Bridge (C step) [Alpine Ridge 2C 2016] (rev 02)
03:01.0 PCI bridge: Intel Corporation JHL6340 Thunderbolt 3 Bridge (C step) [Alpine Ridge 2C 2016] (rev 02)
03:02.0 PCI bridge: Intel Corporation JHL6340 Thunderbolt 3 Bridge (C step) [Alpine Ridge 2C 2016] (rev 02)
04:00.0 System peripheral: Intel Corporation JHL6340 Thunderbolt 3 NHI (C step) [Alpine Ridge 2C 2016] (rev 02)
05:00.0 PCI bridge: Intel Corporation DSL6540 Thunderbolt 3 Bridge [Alpine Ridge 4C 2015]
06:01.0 PCI bridge: Intel Corporation DSL6540 Thunderbolt 3 Bridge [Alpine Ridge 4C 2015]
06:04.0 PCI bridge: Intel Corporation DSL6540 Thunderbolt 3 Bridge [Alpine Ridge 4C 2015]
07:00.0 VGA compatible controller: NVIDIA Corporation GM204 [GeForce GTX 970] (rev a1)
07:00.1 Audio device: NVIDIA Corporation GM204 High Definition Audio Controller (rev a1)
08:00.0 PCI bridge: Intel Corporation DSL6540 Thunderbolt 3 Bridge [Alpine Ridge 4C 2015]
09:00.0 PCI bridge: Intel Corporation DSL6540 Thunderbolt 3 Bridge [Alpine Ridge 4C 2015]
09:01.0 PCI bridge: Intel Corporation DSL6540 Thunderbolt 3 Bridge [Alpine Ridge 4C 2015]
09:02.0 PCI bridge: Intel Corporation DSL6540 Thunderbolt 3 Bridge [Alpine Ridge 4C 2015]
0a:00.0 USB controller: ASMedia Technology Inc. ASM1142 USB 3.1 Host Controller
0b:00.0 USB controller: ASMedia Technology Inc. ASM1142 USB 3.1 Host Controller
0c:00.0 USB controller: ASMedia Technology Inc. ASM1142 USB 3.1 Host Controller
3b:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD Controller SM951/PM951 (rev 01)

Which also recognises my eGPU. I double-checked the PCI numbers and ports in my X11 conf as well, and they seem to match.

My xorg.cong looks like the following

Section "Module"
    Load           "modesetting"
EndSection

Section "Device"
    Identifier     "GTX750"
    Driver         "nvidia"
    BusID          "PCI:07:00.0"
    Option         "AllowEmptyInitialConfiguration"
    Option         "AllowExternalGpus" "True"
EndSection

So what am I overlooking? Why is the second monitor not recognised and not used? (yes tried turning the screen off and on again, as well replugging HDMI cable).

Thanks in advance, any suggestion is more than appreciated

busArray[0]: unbound variable

/usr/bin/egpu-switcher switch auto

[info] Automatically detecting if egpu is connected...
/usr/bin/egpu-switcher: line 138: busArray[0]: unbound variable

PPA changed 'Label' value from 'EGPU Switcher' to 'egpu-switcher'

E: Repository 'http://ppa.launchpad.net/hertg/egpu-switcher/ubuntu bionic InRelease' changed its 'Label' value from 'EGPU Switcher' to 'egpu-switcher'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.

Tried removing the PPA and adding it again, doesn't fix it. I don't want to uninstall egpu-switcher altogether in order to fix this, because it's working so well for me! 💩

p.s. Is there any place I can drop you some $ as a thank you for your work on this? My EGPU is more reliable than the internal card and HDMI port, that's how great this has worked for me.

Internal laptop display not recognized

After setting up egpu-switcher my computer would stop recognizing the internal display and only output to the external display. Everything worked after the initial install but the internal display no longer functioned after closing and opening my laptop lid to wake it from sleep. The screen works whenever it's disconnected from the egpu. A secondary external display connected to the laptop and not the gpu works fine, too. Restarting my pc would sometimes fix the issue on Ubuntu, but I recently switched to Manjaro and after the problem arose it hasn't gone away. Reinstalling and rerunning the script didn't fix anything in Manjaro.

Intel Core i7, Akitio Node, RTX 2060
NVIDIA-SMI 440.82, Driver Version: 440.82, CUDA Version: 10.2

Dell XPS 9760 "Only 1 GPUs found, there need ot be at least 2"

Using a Gigabyte AUROS NVIDIA 1080 and the Dell XPS 9760 I'm getting the following error:

[warn] Only 1 GPUs found, there need to be at least 2. Make sure to connect your EGPU for the setup.

Btw, this is on Ubuntu 18.04.

I imagine it should detect the connected 1080 and the intel intregrated graphics. The eGPU was definitely connected and recognised. At the time of running the eGPU was outputting to an external display (activated using prime-select nvidia).

Does nvidia-prime have to be somehow uninstalled/ deactivated for this to work?

eGPU always shows as disconnected

Hi,
For some reason, no matter what I do my eGPU is always shown as disconnected in eGPU switcher. Even if I plug it in before turning on the laptop.
I've checked boltctl and lspci and both show the card as expected, but the switcher just... Can't find it.

❯ sudo egpu-switcher switch auto
[info] Automatically detecting if egpu is connected... 
[info] EGPU is disconnected.
[info] Create symlink /etc/X11/xorg.conf -> /etc/X11/xorg.conf.internal

My thunderbolt security is set to none, and I believe ACL is on (but if you think that might affect it, I'll double check).

Troubleshooting questions:

  • Installed via git + make
  • Running Fedora 33
  • Using a Dell XPS 13 (2019 2 in 1 model, I think it's the 7390?)
  • Enclosure is a Razer Core X Chroma
  • I'm using the AMDGPU drivers, v19.1.0 from the Fedora repos
  • I'm using KDE + SSDM

This is the relevant bit of boltctl:

 ● Razer Core X Chroma
   ├─ type:          peripheral
   ├─ name:          Core X Chroma
   ├─ vendor:        Razer
   ├─ uuid:          00f18224-bce3-2701-ffff-ffffffffffff
   ├─ generation:    Thunderbolt 3
   ├─ status:        authorized
   │  ├─ domain:     d1465934-070e-8680-ffff-ffffffffffff
   │  ├─ rx speed:   40 Gb/s = 2 lanes * 20 Gb/s
   │  ├─ tx speed:   40 Gb/s = 2 lanes * 20 Gb/s
   │  └─ authflags:  none
   ├─ authorized:    Thu 25 Feb 2021 15:10:35 UTC
   ├─ connected:     Thu 25 Feb 2021 15:10:35 UTC
   └─ stored:        Wed 24 Feb 2021 16:11:42 UTC
      ├─ policy:     iommu
      └─ key:        no

 ● Razer Core X Chroma #2
   ├─ type:          peripheral
   ├─ name:          Core X Chroma
   ├─ vendor:        Razer
   ├─ uuid:          00536824-bce3-2701-ffff-ffffffffffff
   ├─ generation:    Thunderbolt 3
   ├─ status:        authorized
   │  ├─ domain:     d1465934-070e-8680-ffff-ffffffffffff
   │  ├─ rx speed:   40 Gb/s = 2 lanes * 20 Gb/s
   │  ├─ tx speed:   40 Gb/s = 2 lanes * 20 Gb/s
   │  └─ authflags:  none
   ├─ authorized:    Thu 25 Feb 2021 15:10:36 UTC
   ├─ connected:     Thu 25 Feb 2021 15:10:36 UTC
   └─ stored:        Wed 24 Feb 2021 16:19:49 UTC
      ├─ policy:     iommu
      └─ key:        no

(Not sure why it appears twice, maybe that's part of the issue?)
And lspci:

2e:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Hawaii XT / Grenada XT [Radeon R9 290X/390X] (rev 80)
2e:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Hawaii HDMI Audio [Radeon R9 290/290X / 390/390X]

Desktop background and sidebar display artifacts when switching back to "internal"

Context:

I have a clean install of Ubuntu 20.04 on my Lenovo ThinkPad T480, with Intel UHD Graphics 620 and the latest UEFI updates.

I have an Akitio Node eGPU chassis with a Sapphire Radeon R9 Nano GPU.

I have an Iiyama G-Master GB2488HSU monitor connected to the laptop via HDMI and the eGPU via DisplayPort.

Problem:

When I run "sudo egpu-switcher switch internal", restart the computer, and then login again, The desktop background is always dotted with purple and green artifacts.

If I change the background to something else they disappear.

If I select the same background, without removing it from "Background" in "Settings", the artifacts are shown again.

If I remove the same background from "Background" and then add it again they disappear.

If I logout and login again the artifacts appear again, and I need to change the background again as described to get rid of them.

Sometimes artifacts appear on top of the sidebar. I am unable to get rid of these (perhaps there is a command to reload the sidebar). The only way to get rid of them is to logout and login again and hope they are not rendered there.

Evidence:

https://u.pcloud.link/publink/show?code=XZbEJtkZjtcCPoSatdFtjJlN8kF0NkVe8FRX
https://u.pcloud.link/publink/show?code=XZNEJtkZyUb1KqIWk47POK1fqKPgdYOTmNok

Need to reboot twice in order to change de GPU

I have a Linux Mint 20 with the default kernel 5.4.0-40-generic.
I have an intel uhd 620 and a AMD RADEON 5700XT with the eGPU box Razer Core X.
I have configured egpu-switcher with the default option.
When I am with the eGPU and reboot without it the Linux stop booting I just see a cursos blinking.
If I reboot again the intel 620UHD is properly detected.
From the intel 620uhd I reboot with the eGPU plugged it the performance is not good with same lagging in the movements.
But if I reboot again the eGPU is working fine.
Thank you for your support.

cleanup: change "backup not found" message

It seems to be pretty common that the [info] Backup not found, restoring system without xorg.conf message is interpreted as an error message.

Rewrite or completely remove this console output.

systemd service: timing issues - 'switch auto' runs before egpu is connected by bolt

Great work on this project! Only issue with me is that the auto-detect doesn't work for me. In order to get my eGPU working correctly I need to manually set the mode to 'egpu', disable the egpu.service, then reboot.
If i set it to auto with the service enabled, it always chooses the internal symlink.

eGPU is a Razer Core with a AMD RX 580. Machine is a System76 Darter Pro with 10th gen i7 + Intel integrated graphics. Software is Ubuntu Focal (PopOS)

line 372: [: too many arguments

I've actually edited my xorg.conf.egpu file from the generated one, so I know this isn't an expected error, but I think it should still be supported - the grep -Ei "Driver" command on L372 is now returning amdgpu modesetting, which bash interprets as two separate parts, breaking the if condition.

My hacky fix was to surround the command in quotes so that bash sees it as a single string: [ "$(cat $xfile_egpu | grep -Ei 'Driver' | cut -f 2 -d \")" != "nvidia" ]

You may want to find a different way to determine if the returned values contain "nvidia" instead, however - though I don't know exactly what it's used for. I don't have an nvidia card, so I suppose I could've just replaced it with true to the same effect, heh.

19.10 worked for eGPU but then fails on internal

Thanks for the great tool. I was easily able to get it working on 19.10 (with NVIDIA 440 drivers). It directly works for the external GPU, but after a reboot without the eGPU connected, it fails. The error message upon cleanup said something about no backup xorg.conf file. I haven't configured X11 myself in a decade, so this surprised me. I wonder if you have any thoughts about what's going on here or how to overcome it. (I did select to explicitly set the internal GPU even though the default was N.)
Thanks

OpenRC support?

I was wondering if it was possible to make a OpenRC compatible version of this. I think people who use distros without systemd would benefit greatly from this.

"switch egpu" does not create symlink to "xorg.conf.egpu".

Context:

I have a clean install of Ubuntu 20.04 on my Lenovo ThinkPad T480, with Intel UHD Graphics 620 and the latest UEFI updates.

I have an Akitio Node eGPU chassis with a Sapphire Radeon R9 Nano GPU.

I have an Iiyama G-Master GB2488HSU monitor connected to the laptop via HDMI and the eGPU via DisplayPort.

Problem:

When I run "sudo egpu-switcher switch egpu", it does not attempt to create the required symlink between xorg.conf.egpu and xorg.conf.

Conversely, when I run "sudo egpu-switcher switch internal" the required symlink between xorg.conf.internal (which is blank) and xorg.conf is created.

If I manually create the symlink then the eGPU is loaded as the main display device as expected on reboot.

I have tried "sudo egpu-switcher cleanup --hard" followed by "sudo egpu-switcher setup".

I have also tried "sudo egpu-switcher cleanup --hard" followed by "sudo apt purge egpu-switcher", "sudo apt install egpu-switcher" and "sudo egpu-switcher setup".

For each setup step I have selected N when asked if I want to define an internal GPU (answering Y previously caused issues with my Intel GPU but did allow the symlinking to occur).

Evidence:

After running the "sudo egpu-switcher switch egpu" command, there is either no symlink in /etc/X11/ or a symlink to the xorg.conf.internal file.

xorg.conf.internal is empty!

Hi, I'm having the same issue as #55:

❯ sudo egpu-switcher switch auto
[info] Automatically detecting if egpu is connected... 
/usr/bin/egpu-switcher: line 138: busArray[0]: unbound variable

As mentioned in that issue, I don't have a BusID in my active xorg.conf. But that's because, for some reason, I don't have anything in my xorg.conf! I'm not familiar with these files, so I'm not sure what I should expect the file to contain.

The external looks normal:

❯ cat xorg.conf.egpu
Section "Module"
    Load           "modesetting"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "amdgpu"
    BusID          "48:00.0"
    Option         "AllowEmptyInitialConfiguration"
    Option         "AllowExternalGpus" "True"
EndSection

But the internal is just empty. It exists, but has no contents. Any ideas what could have happened?

Applications run on GPU0 instead of GPU1

The card is seen OK, but processes always run on the wrong GPU:

$ nvidia-smi
Sat Oct 19 02:23:06 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 435.21       Driver Version: 435.21       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro M1200        Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   57C    P0    N/A /  N/A |    462MiB /  4046MiB |     18%      Default |
+-------------------------------+----------------------+----------------------+
|   1  GeForce RTX 207...  Off  | 00000000:0B:00.0 Off |                  N/A |
|  0%   34C    P8    16W / 215W |      0MiB /  7982MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1577      G   /usr/lib/xorg/Xorg                           139MiB |
|    0      1682      G   /usr/bin/gnome-shell                          56MiB |
|    0      2482      G   /usr/lib/xorg/Xorg                           209MiB |
|    0      2725      G   /usr/bin/gnome-shell                          53MiB |
+-----------------------------------------------------------------------------+

This is a Precision 5520 with another GPU built in running Ubuntu 18.04.

Looks like something is missing that would tell Xorg to use GPU1, but I am struggling to figure out what it is?

Script stops working with NVIDIA Driver 451.48

I'm on OpenSUSE Tumbleweed. After updating to the latest TW snapshot, which included NVIDIA 451.48, the script stopped working. I tried downgrading to an older kernel, no luck. After I rolled back to an older snapshot, it worked. It seems to be a issue with NVIDIA 451.48. I'm using the git version of the script.

[Feature request] Add the possibility to execute some custom commands when switching the gpu configuration

Hi !

The contexte is the same as issue #72, I still have the same laptop ;)

Context

I have a laptop with an Intel GPU and a Nvidia Quadro. It works fine, if I want to run programs on my nvidia card I can use prime-run, else they will be executed on the Intel GPU.

Now, I would like to use a eGPU. The eGPU is visible from the system even without any xorg configuration. However, when I perform a "DRI_PRIME=1 glxgear", I'll have some libGL errors and the glxgear window will remain black, because the nvidia_drm module is loaded. The solution is to rmmod it, and then programs launched with DRI_PRIME=1 will work fine. However, this rmmod has to be done before Xorg is launched.

Feature request

Would it be possible to add, in the egpu-switcher configuration file, some fields which will have some command to run when switching the GPU profile ?
With this, I'll be able, for example, to execute a "echo 'blacklist nvidia_drm' > /etc/modprobe.d/egpu.conf && rmmod nvidia_drm" when switching to the eGPU profile, and a "echo '' > /etc/modprobe.d/egpu.conf" when switching to the internal profile.

Thank you

System informations :

  • Did you install egpu-switcher via ppa or via git + make : egpu-switcher is installed from AUR (so it's kind of git+make)
  • What Linux distribution (+ version) are you using : Archlinux
  • What brand / model is your laptop : Dell precision 7510 with NVidia Quadro
  • What brand / model is your GPU (+ enclosure) : AMD RX580 + Akitio Node
  • What drivers (+ version) are you using : latest amdgpu and nvidia 470
  • What Desktop-Environment do you use (+ Display-Manager) : Xorg with FVWM (no DE)

Changelog

I don't see a change log under releases. Is there one somewhere else? Given that this is important to my system being usable it would be nice to see what changes were made outside of having to do a git blame.

Thanks for your hard work on this, btw.

Get rid of the `nvidia-xconfig` option

The nvidia-xconfig method of reading out the gpus doesn't seem to work properly after altering the xorg.conf files. Since the lspci way of detecting the GPUs works pretty seamlessly we should get rid of the nvidia-xconfig option. This would strip out a lot of never used legacy code.

missing release files for 20.04 focal

I just installed your egpu-switcher on latest Ubuntu 20.04 focal release and can confirm it working without any issues my friend 👍
It would be nice if you could create the release files for focal on launchpad

To install your egpu-switcher I had to manually edit the apt file to point it to bionic main

Unable to update in Ubuntu 18.04.3

I have not tried using egpu-switcher yet, so I don't think there are any config files. But at the moment it is failing to update.

sudo egpu-switcher cleanup --hard
[info] Starting cleanup process
[info] Removing configuration files (--hard)
Failed to stop egpu.service: Unit egpu.service not loaded.

sudo apt full-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
libpoppler85
The following packages will be upgraded:
egpu-switcher
1 to upgrade, 0 to newly install, 0 to remove and 1 not to upgrade.
Need to get 0 B/8,288 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 315582 files and directories currently installed.)
Preparing to unpack .../egpu-switcher_0.12.0_amd64.deb ...
[info] Starting cleanup process
Failed to stop egpu.service: Unit egpu.service not loaded.
dpkg: warning: old egpu-switcher package pre-removal script subprocess returned error exit status 5
dpkg: trying script from the new package instead ...
[info] Starting cleanup process
Failed to stop egpu.service: Unit egpu.service not loaded.
dpkg: error processing archive /var/cache/apt/archives/egpu-switcher_0.12.0_amd64.deb (--unpack):
new egpu-switcher package pre-removal script subprocess returned error exit status 5
Errors were encountered while processing:
/var/cache/apt/archives/egpu-switcher_0.12.0_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Script ends prematurely

My setup: Arch Linux, Razer Blade Stealth 2019 Mercury White (without any DGPU), Razer Core X, RX 5700 XT.

Problem: Whenever I run the egpu-switcher script, it somehow ends prematurely inside this block:

for disp in ${disp_path}; do
	if [ -e $disp ]; then
		disp_num=$(expr $disp_num + 1)
		disp_disconnect=$(expr $disp_disconnect + $(cat $disp | grep -ce ^disconnected$))
	fi
done

Bash debug output ends with this:

+ echo -e '\033[1;34m[info]\033[0m EGPU is \033[1;32mconnected\033[0m.'
[info] EGPU is connected.
+ gpu_connected=1
+ '[' 1 = 1 ']'
+ mode=egpu
+ '[' egpu = egpu ']'
++ grep -ce nvidia /etc/X11/xorg.conf.egpu
+ '[' 0 -eq 0 ']'
++ cat /etc/X11/xorg.conf.egpu
++ grep -Ei BusID
++ grep -oEi '[0-9]+\:[0-9]+\:[0-9]+'
+ declare egpu_pci_id=48:0:0
+ busArray=(${egpu_pci_id//:/ })
+ declare busArray
+ declare bus1d=48
+ declare bus2d=0
+ declare bus3d=0
++ printf %02x 48
+ declare bus1h=30
++ printf %02x 0
+ declare bus2h=00
++ printf %01x 0
+ declare bus3h=0
++ echo 30:00.0
+ declare hex_id=30:00.0
+ declare 'disp_path=/sys/bus/pci/devices/[0-9a-f:]*30:00.0/drm/card[0-9]*/card[0-9]*-*/status'
+ declare disp_num=0
+ declare disp_disconnect=0
+ for disp in ${disp_path}
+ '[' -e /sys/bus/pci/devices/0000:30:00.0/drm/card1/card1-DP-6/status ']'
++ expr 0 + 1
+ disp_num=1
+++ cat /sys/bus/pci/devices/0000:30:00.0/drm/card1/card1-DP-6/status
+++ grep -ce '^disconnected$'
++ expr 0 + 0
+ disp_disconnect=0

and then it ends.

Bash is really not my cup of tea so maybe I'm missing something? Workaround for me is to just delete the whole disconnected display verification block.

Failed to start EGPU service

I was using my egpu, shut down, might have unplugged too early (don’t think I did), and when I boot up my computer I’m met with “Failed to start EGPU service“ after I decrypt my drive. Seems to be an endless loop. Plugging in the egpu and booting that way doesn’t solve the problem.

41CE9B87-1402-4BF7-B06B-305D8C14952F

Stopped working.

Not sure exactly why. It's been working for weeks. Yesterday, I had shut down my laptop, was working in the other room without egpu. Plugged back into the egpu today, and my laptop is no longer switching to the egpu upon several startups and retries on the configuration. I even ran cleanup, and setup all over agin. Thunderbolt is approved, and nvidia-sma produces :

Tue Jun 16 13:15:06 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.64       Driver Version: 440.64       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce MX150       Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   59C    P8    N/A /  N/A |     92MiB /  2002MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   1  GeForce GTX 1080    Off  | 00000000:08:00.0 Off |                  N/A |
| 27%   32C    P8     5W / 180W |      2MiB /  8119MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1219      G   /usr/lib/xorg/Xorg                            92MiB |
+-----------------------------------------------------------------------------+

As you can see the MX150 is at 92MiB, and GTX1080 is at 2MiB (which never goes up because it's not being used).

Please help. If there is anything I can do to test let me know. I'm going to dive into closed issues in the meantime.

Prevent "No such file or directory" output in switch command

Some users might see the following output when executing the egpu-switcher switch egpu command.

ls: cannot access '/sys/bus/pci/devices/0000:09:00.0/drm/card[0-9]*/card[0-9]*-*/status': No such file or directory
cat: '/sys/bus/pci/devices/0000:09:00.0/drm/card[0-9]*/card[0-9]*-*/status': No such file or directory

That's not an error, but just an output of the script while it checks if those directories exist.
It would be more user-friendly to hide this output from the end-user.

Related to PR #14

Detecting gpu from egpu-switcher conf file instead of Xorg file

Hi !

Some context :
I have a laptop with an Intel GPU and a Nvidia Quadro. It works fine, if I want to run programs on my nvidia card I can use prime-run, else they will be executed on the Intel GPU.
Now, I would like to use a eGPU. With egpu-switcher, the generated Xorg configuration put the eGPU as the Sink device and the Intel GPU as a secondary GPU. Which means the X programs are run by default on the eGPU, and the laptop screen (which is connected to the Intel GPU) has many tearing problems.
I fixed this with a custom xorg.conf.egpu with defines the Intel GPU as the main one, and in order to run programs on the eGPU I have to prefix them with a DRI_PRIME=1. This way, with a eGPU connected I have more or less the same behaviour : for running programs on the most performant GPU I have to execute them with a prefixe (either DRI_PRIME=1 or prime-run), and without it they will be run on the Intel GPU.
But with this xorg.conf.egpu file, the eGPU detection doesn't work because I have the 3 PCI GPU card in it, and the first one is the Intel GPU.

The issue
However, since a egpu-switcher config doesn't override the xorg.conf files which allow me to have my custom conf, and has its own conf file with the eGPU PCI Bus, would it be possible to replace the line 134 "declare egpu_pci_id=$(cat $xfile_egpu | grep -Ei "BusID" | grep -oEi '[0-9]+:[0-9]+:[0-9]+')" by "declare egpu_pci_id=$(cat $config_file | grep "external_gpu" | cut -d '=' -f2" ?
With this, it will allow users to have a custom xorg.conf.egpu file with a working eGPU detection.

Thank you

System informations :

  • Did you install egpu-switcher via ppa or via git + make : egpu-switcher is installed from AUR (so it's kind of git+make)
  • What Linux distribution (+ version) are you using : Archlinux
  • What brand / model is your laptop : Dell precision 7510 with NVidia Quadro
  • What brand / model is your GPU (+ enclosure) : AMD RX580 + Akitio Node
  • What drivers (+ version) are you using : latest amdgpu and nvidia 470
  • What Desktop-Environment do you use (+ Display-Manager) : Xorg with FVWM (no DE)

login loop on ubuntu 20.04

I have a dell xps 13 with dual booted ubuntu and windows.

I recently reinstalled ubuntu, and after installing egpu switcher started encountering a login loop on startup.

Checking /var/log/Xorg.0.log revealed had an error saying no screen found.
Manually switching to egpu from ttl3 fixes this and allows me to login.
However I have to do this every time I turn on my laptop.

I have a bios setting enabled that prevents things connected through egpu working in grub, my best guess is that there is some sort of a race condition happening.

Anyway not sure if it's a bug or even fixable, but thought I'd post it here for awareness.

video cards on non-zero PCI domains aren't configured correctly

This is a follow-up issue for issue #59 and PR #68.

The PCI Domain of the lspci -D command is simply ignored right now. Therefore, any video card on a non-zero PCI domain won't be configured correctly in xorg.conf.

The BusID option in xorg.conf should include the PCI domain, to resolve this issue.

Snippet from xorg.conf manpage:

BusID  "bus-id"
        This specifies the bus location of the graphics card.  For PCI/AGP cards,  the  bus-id
        string  has  the form PCI:bus@domain:device:function (e.g., "PCI:1@0:0:0" might be ap-
        propriate for an AGP card). The "@domain" part can be left out for PCI domain 0.  This
        field  is usually optional in single-head configurations when using the primary graph-
        ics card.  In multi-head configurations, or when using a secondary graphics card in  a
        single-head  configuration,  this  entry is mandatory.  Its main purpose is to make an
        unambiguous connection between the device section and the hardware it is representing.
        This information can usually be found by running the pciaccess tool scanpci.

The BusID has the form of PCI:bus@domain:device:function. The @domain part is currently left out, which implicitly sets the domain to 0.

can't get eGPU working on Ubuntu20.04 ( Aorus GTX 2080TI Gaming Box )

Hi,

I recently purchased an external GPU, specifically the GIGABYTE Aorus GTX 2080ti Gaming Box to use with my laptop, I have a Dell G5 RTX2060 running Ubuntu 20.04. And my egpu can be authorized but can’t be used.

I try to reinstall the nvidia driver to suit both of gpu, but it is helpless. Everything seems to be normal, but the nvidia-smi can't recognize the egpu and I can't use it....

Can anyone help me? Thanks.

2021-07-09_20-18
image
image

Support selection of eGPUs

I currently switch between 3 different eGPU scenarios:

  1. Undocked (i.e. no eGPU)
  2. Docked with AMD eGPU
  3. Docked with Nvidia eGPU

Currently, it doesn't seem possible to have 3 different Xorg .confs that the startup script selects from. This means that whenever I switch from AMD to Nvidia, or vice-versa, I need to recreate the configuration for egpu-switcher.

Improve eGPU detection

Currently, the eGPU detection is solely based on the PCI ID, and there are no further checks about the connected device.
This can cause false-positives in the eGPU detection method, if another device (ie. a normal Thunderbolt 3 Docking Station) is connected instead of the eGPU.

I'm using my notebook at home with an eGPU, and at my workplace with a TB3 Docking Station.
When booting up the system at work, it falsely detects it as the eGPU, since its USB Controller gets connected on the same BUS-ID as my eGPU at home. This causes the display-manager to throw an error and requires the following manual steps on another tty on every bootup.

sudo egpu-switcher switch internal
sudo systemctl restart display-manager

Updating/Removing package causes error if egpu-switcher has not been set up

Thanks for the new release.
I get a problem when updating under ubuntu 19.10

$ sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  egpu-switcher
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/8.288 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
(Reading database ... 293437 files and directories currently installed.)
Preparing to unpack .../egpu-switcher_0.12.0_amd64.deb ...
[info] Starting cleanup process
Failed to stop egpu.service: Unit egpu.service not loaded.
dpkg: warning: old egpu-switcher package pre-removal script subprocess returned error exit status 5
dpkg: trying script from the new package instead ...
[info] Starting cleanup process
Failed to stop egpu.service: Unit egpu.service not loaded.
dpkg: error processing archive /var/cache/apt/archives/egpu-switcher_0.12.0_amd64.deb (--unpack):
 new egpu-switcher package pre-removal script subprocess returned error exit status 5
Errors were encountered while processing:
 /var/cache/apt/archives/egpu-switcher_0.12.0_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

awk error in Manjaro linux

When running gswitch setup the following error occurs in Manjaro linux

  • sudo gswitch setup
    awk: cmd. line:1: warning: regexp escape sequence `\"' is not a known regexp operator

It may be related to different versions of gawk.

  • gawk -V:
    GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)

Release ubuntu 21.04 package

Could you add support for ubuntu 21.04 via packages.
It currently won't install on it. Here's the message log when running apt-get update after adding the ppa.

E: The repository 'http://ppa.launchpad.net/hertg/egpu-switcher/ubuntu hirsute Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Note: The 20.10 packages work perfectly on 21.04.

GPU detection: Intel Corporation Device a33d (rev f0) (0:28:5)

My laptop has an interesting device. 😉

$ sudo egpu-switcher config

Found 4 possible GPUs...

  1: Intel Corporation Device a33d (rev f0) (0:28:5)
  2: NVIDIA Corporation GM108M [GeForce MX130] (rev a2) (2:0:0)
  3: NVIDIA Corporation GM204 [GeForce GTX 970] (rev a1) (8:0:0)
  4: Intel Corporation Device 3e9b (0:2:0)

Would you like to define a specific INTERNAL GPU? [y/N]: 

lspci -nn shows the culprit:

$ lspci -nn| grep -i -E "^[^\s]+\s+.*(vga|3d)"
00:02.0 VGA compatible controller [0300]: Intel Corporation Device [8086:3e9b]
00:1c.5 PCI bridge [0604]: Intel Corporation Device [8086:a33d] (rev f0)
02:00.0 3D controller [0302]: NVIDIA Corporation GM108M [GeForce MX130] [10de:174d] (rev a2)
08:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM204 [GeForce GTX 970] [10de:13c2] (rev a1)

Sure, the most compatible workaround will be tuning the grep parameters, like:

$ lspci -nn| grep -i -E "^[^\s]+\s+.*(vga compatible|3d) controller"
00:02.0 VGA compatible controller [0300]: Intel Corporation Device [8086:3e9b]
02:00.0 3D controller [0302]: NVIDIA Corporation GM108M [GeForce MX130] [10de:174d] (rev a2)
08:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM204 [GeForce GTX 970] [10de:13c2] (rev a1)

But the usage of -d switch (which is able to filter based on class, since pciutils v3.3.0) would be more elegant:

$ (lspci -d ::0300 && lspci -d ::0302)|sort
00:02.0 VGA compatible controller: Intel Corporation Device 3e9b
02:00.0 3D controller: NVIDIA Corporation GM108M [GeForce MX130] (rev a2)
08:00.0 VGA compatible controller: NVIDIA Corporation GM204 [GeForce GTX 970] (rev a1)

(The sort is only needed for the same order of lines, which is irrelevant for egpu-switcher)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.