Setting Up and Switching Between an NVIDIA eGPU on Ubuntu 22.04: A Step-by-Step Guide

San on 2023-12-02

Are you stuck with a blinking cursor after disconnecting your eGPU from your PC?

This guide is for you! Learn how to set up your eGPU correctly so you can unplug it as needed without destroying the GNOME display or messing up your Ubuntu. This guide aims to simplify the process of installing and seamlessly switching between an NVIDIA eGPU and the integrated graphics on Ubuntu 22.04.

Installation Steps:

Step 1: Initialize Your Device

  1. Connect Your eGPU: Begin by plugging in your external GPU. Ensure it’s properly connected to your system via the Thunderbolt port.
  2. Authorize in Thunderbolt Settings: If your system prompts for authorization, confirm it in the Thunderbolt settings to allow the eGPU to communicate with your system.
  3. Verify the Connection: To confirm that your eGPU is recognized by your system, use the following command in the terminal:
lspci

Step 3: Install Appropriate NVIDIA Drivers

  1. Determine Compatible Drivers: If your system includes an internal GPU, it’s crucial to install NVIDIA drivers that are compatible with both your internal and external GPUs. To find out which NVIDIA driver is suitable for your system, use the command:
ubuntu-drivers devices

If you already had nvidia driver in your system, let’s uninstall it first:

sudo apt-get purge nvidia-*
sudo apt autoremove

2. Install NVIDIA Drivers: Once you’ve identified the appropriate driver version, install it using the following command:

sudo apt install nvidia-driver-xxx

Step 3: Install egpu-switcher

Egpu-switcher Simplifies the Process of Modifying Your eGPU Configuration.”

Download binary release: https://github.com/hertg/egpu-switcher/releases Install with:

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

Step 4: Reboot and check settings:

Reboot system:

sudo reboot

Use the nvidia-smi command to confirm that both your Internal and External GPUs are properly detected.

To deactivate or switch away from using your eGPU. Run the command

Shutdown your PC and unplug eGPUs.

To activate your eGPU, simply plug it in and restart your computer.

To make sure your config, run egpu-switcher config and set your eGPU as external GPU.

sudo egpu-switcher config