egpu-linux-install
Installing external GPU enclosure for use on laptop running Linux distribution; utilizing hertg’s egpu-switcher
script to facilitate
Prerequisites
- a Thunderbolt 3-compatible (or newer) laptop PC running a Linux desktop operating system based on one of the following: Ubuntu, Fedora, Arch (in my case, we will be using Pop!_OS 22.04 LTS)
sudo
or administrator privileges
- an internet connection
- a Thunderbolt 3-compatible (or newer) external GPU enclosure with discrete graphics card (in my case, I will be using a Cooler Master EG200 with an RTX 2060)
1. Install dependencies for script
- hertg’s script requires the
Go
toolchain to be installed for building from source; open your terminal and enter the commands as follows:
- clone the Go source code:
wget https://go.dev/dl/go1.20.2.linux-amd64.tar.gz
- remove any previous installations of Go:
sudo rm -rf /usr/local/go
- extract the Go source code to our runtime directory:
sudo tar -C /usr/local -xzf ./go1.20.2.linux-amd64.tar.gz
(your archive tar name may differ from mine; at the time of writing, 1.20.2 is the latest stable version of the Go toolchain)
- Add the Go binary to your
PATH
:
- for one-time use:
export PATH=$PATH:/usr/local/go/bin
- for permanent or repeated use, edit your .bashrc (.zshrc in my case) in your home directory (/home/user/), and add the above
export
line at the very end.
- Either close and re-open your terminal, or issue the following command:
source .bashrc
- Verify your Go installation with the following command:
go version
- the output should match the following:
go version go1.20.2 linux/amd64
(again, your version number may differ)
- To cover the bases, install your regular build dependencies with the following command:
sudo apt install build-essential gcc make
(you may receive output that these packages are already installed, if so skip to step 2)
- If you are on Pop!_OS, you may already have the necessary Nvidia drivers depending on which image you downloaded when you installed the OS on your laptop; confirm you have the necessary Nvidia drivers with the following command:
nvidia-smi
- if you receive a message about “command not found”, install the necessary nvidia drivers with the following command and reboot once completed:
sudo apt install system76-driver-nvidia
- if you are not running Pop!_OS, refer to this link for your distribution’s specific instructions for installing: System76 Driver (Install) - System76 Support
- If you are on Pop!_OS, you already have the necessary
system76-power
package to enable graphics switching; if you are on stock Ubuntu or a derivative, Fedora, or an Arch-based distribution, follow the steps below based on your specific needs:
2. Clone script source and prepare build environment
- Create a “temp” directory to clone the source code for hertg’s
egpu-switcher
script; in my case, we will create a “.tmp” folder in our home directory: mkdir ~/.tmp
- Change directories into “.tmp”:
cd ~/.tmp
- Clone the source code from GitHub:
git clone https://github.com/hertg/egpu-switcher
- Change directories into the source code folder:
cd egpu-switcher
- Build the installation:
make build -s
- you will see multiple lines about “go” downloading dependencies; this is fine as long as the last line of output matches:
binary compiled => ./bin/egpu-switcher
- Install the script:
sudo make install -s
- your output should match the following:
binary installed at /usr/bin/egpu-switcher
docs generated => ./docs
manpages installed in /usr/share/man/man1
- At this point, go ahead and plug in your eGPU and power it on
- Confirm the eGPU is detected by observing both of the following:
- your laptop now shows it is connected to power and charging;
- “Settings > Privacy > Thunderbolt” shows the eGPU enclosure as “Authorized”
- If the eGPU is not automatically detected, unplug, reboot, and plug back in
- In your terminal, issue the following command:
sudo egpu-switcher enable
- if the steps up to this point have been followed, you should be presented with two options; enter the corresponding number for the
nvidia
option, then reboot your PC with the eGPU still plugged in
- the egpu-switcher script creates the necessary symbolic links and a startup service for the laptop to recognize the GPU at boot when the GDM service is started.
- You should now be able to run
nvidia-smi
in your terminal and receive a snapshot of your eGPU’s current driver version, processing/memory load, and temperature.
4. Credits
- hertg, developer of the
egpu-switcher
script; you can follow his work on GitHub here: hertg (Michael Hertig) - GitHub
- S31bz, responsible for informing me of the Cooler Master EG200’s real-world Linux compatibility after his own configurations with an AMD GPU and Framework 11th Gen laptop (source); you can follow S31bz’s work on his website here: Alex Seibz’ Site
5. DISCLAIMERS - WIP
- This document is written with the assumption of an Nvidia GPU; steps may differ for AMD, which this guide will not cover.
- If you have an AMD GPU, your drivers are already baked into the
mesa
package provided by either the nvidia
or intel
Pop!_OS ISOs; no further driver configuration is needed.
- As of yet, there is NO hot-plug support for external graphics in Linux. You will need to reboot your laptop before you can utilize the eGPU. This is for both Nvidia AND AMD cards.
- There may be a slight perceived bottleneck on the GPU’s performance if pushed; Thunderbolt 3 exposes a maximum of 4 PCIe 3.0 lanes, and most GPUs work at x16-lane speeds in a regular desktop PC.