[TRACKING] Fun weekend project: Testing a new NVIDIA eGPU Switcher

Personal project on my own time. However, if this works out half as well as it has thus far, I’ll make this official.

egpu-switcher-test

(Click image to see the video)

Off today, so just messing about. Testing the Framework eGPU switcher. Nothing glamorous, just something I put together using a little bash script, a launcher. I wasn’t thrilled about alternatives out there as I didn’t like how the user was left guessing what to do next.

  • Install.
  • Click an icon.
  • Choose a number.
  • Receive a clear confirmation that it switched.
  • Automatic logout so it can take affect once logged back in.
  • Works flawlessly on Ubuntu 22.04.1 Wayland and Xorg using nvidia-prime.

So what’s wrong with egpu-switcher and others on Github? Nothing specifically, when they work. Also, some aren’t very clear if they worked or not. This works, with NVIDIA, well.

Not releasing the script yet as I want the install script to do the following:

UPDATED

  • Complete a bit more testing before releasing this.
9 Likes

Please make sure to not add unnecesary dependencies like systemd for systems/distros which do not use such.

Also, thanks for tinkering around with it! I am planning to get an eGPU as well, I will probably get the Razor Core X enclosure, but no idea which GPU yet.

1 Like

Agreed. All that is installed is:

libnotify, nvidia-prime, figlet, nvidia-driver-525-open, nvidia-prime and nvidia-settings. All super basic stuff.

I used figlet for the fun text telling us “clearly” that the switch worked.

That’s it. :wink:

Part of what turned me off from alternatives was needing systemd and “Go.”

1 Like

Well folks, we have a winner. My simple script works really well, handles all the guesswork and heavy lifting. :slight_smile: The first Framework NVIDIA eGPU Switcher tool is nearly ready.

It’s working!

When ready, this is tested on Ubuntu 22.04.1. Designed this to work on anything using apt, can also be configured for other packaging environments as well.

Installer script handles it all. Shortcuts, GPU detection, etc, all you do is use it.

working

  • So when you hit the icon, you are asked to press 1 or 2.

  • I pressed 2, NVIDIA.

  • Then I am automatically prompted to logout.

  • Logging back in (Wayland or Xorg, doesn’t matter). The tool pings nvidia-smi

  • If Nvidia is active, it tells me NVIDIA. If not, I get Intel.

So this is super bloaty, right? Nope.

  • The whole thing is free of systemd or python or Go. Only expects libnotify, nvidia-prime, figlet, nvidia-driver-525-open, nvidia-prime and nvidia-settings. All super basic stuff.

  • The installer tool handles (Ubuntu) the installation of everything needed. You configure nothing.

  • All you need to do is access the tool from Activities.

  • Or add it to your favorites from Activities for easier access.


Switching back to Intel.

Log out as prompted.

Then upon logging back in, rock solid CONFIRMATION that I am using Intel by not assuming, but actually checking to make sure.

little-Intel-Notify

then I can see it. I did it this way as I care less about being notified.

This can be adjusted for NVIDIA or Intel with changes to notify-send --urgency=critical or notify-send --urgency=normal or notify-send --urgency=low. It’s just a script, easy to edit and customize.

10 Likes

Nice! When the code is released I’ll try to add support for AMD.

3 Likes

Outstanding! Will let you know. Appreciate the assist!

Excellent project!!
It is using nvidia (or even nvidia-open) drivers, or nouveau drivers?
I have made many attempts at “adding” a nvidia Xorg provider (so that it appears in xrandr --lisproviders) without restarting X (and killing all X apps in the process), but I failed, and when I discovered it seemed to work OOTB in Ubuntu it was actually with nouveau (which seems to already handle this kind of hotplugging) not with nvidia.

Also, while Googpling, I saw attempts to add hotplugging support for amdgpu driver with a HotplugDriver X option.

All of that made me believe that some drivers (nouveau, maybe amdgpu) where hotpluggable, while others (nvidia) required a restart of the X server.

But now with your project I hope I was wrong!!? :smile:

1 Like

nvidia-driver-525-open is a metapackage. Head package is nvidia-driver-525. Not the FoSS Nvidia driver.

The secret sauce is to use the tech Nvidia has given us. Got the idea using the prime switcher applet in MATE. Worked so well, I made something in its spirit. But with some checks in place.

I have not tested hotpluging.

Still in testing phase atm.

2 Likes

I see, many thanks!! I can’t wait to try it, and have an attempt at adapting it to my Artix distro!!

By the way, does it work even for hot-unplug? Ah you just answered that (hotpluging not yet tested)! Thx.
That would be very nice, to take out the laptop to the couch after a session using the eGPU, without having to close everything in the process!

Edit: oh, now I see that in your script there is a prompt asking to logout, which I think allows Xorg to restart. I had overlooked it. I believe that requires to close all running X apps beforehand? Not going to lie, my ultimate aim would be that there would be no need to logout anymore! And it seems that the nouveau drivers allows just that.

1 Like

Yeah, not needing to logout is an ultimate goal. The logout was used for xorg and Wayland.

My primary focus is making sure it works. If logging out is the price I have to pay, I’m perfectly fine with it.

My goal is simplicity with reliability. So that’s the first order I’m working on. :slight_smile:

3 Likes

Love this, the biggest annoyance for me is that I have to reboot when switching to my AMD eGPU.

Can’t wait to see where this lands

1 Like