GithubHelp home page GithubHelp logo

quinndiggity / egpu-switcher Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hertg/egpu-switcher

0.0 1.0 0.0 260 KB

๐Ÿ–ฅ๐Ÿง Setup script for eGPUs in Linux (XServer)

License: GNU General Public License v3.0

Shell 97.09% Makefile 2.91%

egpu-switcher's Introduction

egpu-switcher

Disclaimer
Works with NVIDIA as well as AMD cards.
Tested on Ubuntu, Arch and many other distros.

For more information and user feedback, take a look at my Thread over on egpu.io or open an issue on Github.

Description

The goal of this script is to make the initial egpu setup for (new) Linux users less of a pain. With this script your X-Server configs for the different GPUs will be automatically created, you just have to choose which one is the external and which the internal graphics card.

After the setup, your linux installation will at each startup check if your EGPU is connected or not, and then automatically choose the right X-Server configuration in the background.

This does not provide you with a plug-and-play functionality like you may know from Windows. If you want do connect / disconnect your EGPU, you will have to restart your computer.

Screenshot

Screenshot of setup

Requirements

  1. Your OS is running X-Server.
  2. You have at least pciutils 3.3.x or higher installed (check with lspci --version).
  3. You have at least Bash 4.x or higher installed.
  4. You have already authorized your Thunderbolt EGPU and are able to connect.
  5. You have already installed the latest (proprietary) drivers for your GPUs.

TL;DR

Ubuntu (apt)

Installation and setup:

$ sudo add-apt-repository ppa:hertg/egpu-switcher
$ sudo apt update
$ sudo apt install egpu-switcher
$ sudo egpu-switcher setup

Uninstall:

$ apt remove egpu-switcher

Other

Installation and setup:

$ git clone [email protected]:hertg/egpu-switcher.git
$ cd egpu-switcher
$ make install
$ sudo egpu-switcher setup

Uninstall:

Critical Warning: Do not use this command on any version prior to 0.10.2!
There was a critical typo in the Makefile which would delete your /usr/bin folder. Please do a manual uninstall by removing the egpu-switcher folder in the /usr/bin/ and the /usr/share/ directory.

$ sudo egpu-switcher cleanup
$ make uninstall

Hint: Up until version 0.12.0 there was an issue that the cleanup command needed the egpu-switcher to be set up for the cleanup to work. If you are having trouble to cleanup, remove or upgrade the egpu-switcher take a look at this possible fix.

Commands

egpu-switcher setup [--override] [--noprompt]
    This will generate your "xorg.conf.egpu" and "xorg.conf.internal" files and 
    symlink the "xorg.conf" file to one of them.

    It will also create the systemd service, that runs the "switch" command on each startup.

    The setup will NOT delete any of your files, if you have an existing "xorg.conf"
    file it will be backed up to "xorg.conf.backup.{datetime}". You can later revert
    it by executing the "cleanup" command (see below).

    --override
        If you have an AMD GPU or use the open-source nvidia drivers, 
        the "switch" command will prevent you from switching to the EGPU
        if there are no displays directly attached to it. This flag will
        make sure to switch to the EGPU even if there are no displays attached.

    --noprompt
        Prevent the setup from prompting for user interaction if there is
        no existing configuration file found. 
        (Is currently only used by the "postinst" script)
egpu-switcher switch auto|egpu|internal [--override]
    Switches to the specified GPU (egpu|internal). If the auto parameter 
    is used, the script will check if the egpu is attached and switch accordingly.
    
    You need to restart your computer (or display-manager) for this to take effect.

    --override
        If you have an AMD GPU or use the open-source nvidia drivers, 
        the "switch" command will prevent you from switching to the EGPU
        if there are no displays directly attached to it. This flag will
        make sure to switch to the EGPU even if there are no displays attached.
egpu-switcher config
    Prompts the user to specify their external/internal GPU and saves their answer
    to the configuration file.
egpu-switcher cleanup [--hard]
    Remove all files egpu-switcher has created previously and restore the backup
    of previous "xorg.conf" files.

    --hard
        Remove configuration files too.

Hints

  1. Ubuntu 19.04 or later
    When installing Ubuntu 19.04 or later, please check the box "Install third-party software for graphics and Wi-Fi hardware". After that, all required drivers will be installed automatically.

  2. Notebooks with hybrid graphics
    I am using a Lenovo notebook with hybrid graphics (internal graphics and a dedicated GPU). I've experienced freezes in the Ubuntu 19.04 installer which could only be resolved by changing the display settings in the BIOS from Hybrid Graphics to Discrete Graphics. After the installation was complete, i was able to change this setting back to Hybrid Graphics, without any issues.

Background information

A backup of your current xorg.conf will be created, nothing gets deleted. If the script doesn't work for you, you can revert the changes by executing egpu-switcher cleanup or just completely uninstall the script with apt remove egpu-switcher. This will remove all files it has created and also restore your previous xorg.conf file.

This script will create two configuration files in your X-Server folder /etc/X11. The file xorg.conf.egpu holds the settings for your EGPU and the file xorg.conf.internal holds the settings for your internal graphics.

Then a symlink xorg.conf will be generated which points to the corresponding config file, depending on wheter your egpu is connected or not.

Additionally a custom systemd service with the following content will be created.

/etc/systemd/system/egpu.service

[Unit]
Description=EGPU Service

[Service]
Type=oneshot
ExecStart=egpu-switcher switch auto

[Install]
WantedBy=multi-user.target

This will enable the automatic detection wheter your egpu is connected or not on startup.

Build (notes to myself)

  1. sudo apt install devscripts
  2. sudo apt install debhelper
  3. Update changelog: dch
  4. Build: debuild -S | tee /tmp/debuild.log 2>&1
  5. Upload to ppa: dput ppa:hertg/egpu-switcher egpu-switcher_X.X.X_source.changes

egpu-switcher's People

Contributors

ewagner12 avatar hertg avatar maddocker avatar marcolaux avatar xabolcs avatar

Watchers

 avatar

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.