Use an eGPU with Ubuntu

If you want to figure out how to use an Nvidia card with an external GPU case connected to your Ubuntu laptop, this is the place.

My gear

This doc was tested with the following hardware:

Set up

  1. After you plug your eGPU to a Thunderbolt port on your laptop, open the Ubuntu settings and allow Direct Access to your device:

    Allow Thunderbolt access
  2. Afterwards, install the Nvidia propriety drivers. Something like this should do the trick:

    sudo ubuntu-drivers autoinstall
    
  3. Install the Nvidia configuration settings to manage your card:

    sudo apt install nvidia-settings
    
  4. Install nvidia-prime to switch between your integrated graphics and the external card:

    sudo apt install nvidia-prime
    

Of course you can do all of this from the graphical interface, but that’s too many steps. I rather use the terminal and be done with it.

Switch to external GPU

At this point you can open Nvidia X Server Settings and select the NVIDIA profile:

Nvidia Settings

Or from the terminal, run:

sudo prime-select nvidia

Reboot and you won’t be able to log in. I poked around the logs and found this:

NVIDIA(GPU-0): This device is an external GPU, but external GPUs have not
been enabled with AllowExternalGpus. Disabling to prevent crashes from
accidental removal.

Failing initialization of X screen 0

So I somehow have to tell Ubuntu to allow external GPUs. With your favorite plain text editor open /usr/share/X11/xorg.conf.d/10-nvidia.conf and edit it so it looks like this:

Section "OutputClass"
         Identifier "nvidia"
         MatchDriver "nvidia-drm"
         Driver "nvidia"
         Option "AllowEmptyInitialConfiguration"
         Option "AllowExternalGpus" "true"
         ModulePath "/usr/lib/x86_64-linux-gnu/nvidia/xorg"
EndSection

Reboot your computer and open the Nvidia settings program, you see your card working:

Working nvidia settings

You might have to do this every time you update your drivers. Every new installation overwrites this file.

Blacklist some stuff

# file /etc/modprobe.d/blacklist.conf

## Nvidia-related stuf
blacklist nouveau
blacklist nvidiafb

That should do it

External monitor not working

So Ubuntu tells me the graphics card is working, but when I plugged a monitor to the Razer Core nothing happened. Blank screen.

To fix this, edit the file /lib/modprobe.d/nvidia-kms.conf so it looks like this:

# This file was generated by nvidia-prime
# Set value to 0 to disable modesetting
options nvidia-drm modeset=0

Reboot and that’s it. Everything should be working.