GithubHelp home page GithubHelp logo

Comments (6)

ewagner12 avatar ewagner12 commented on July 21, 2024 2

Hi @T-X I actually have the same laptop as you, nice.

For this hardware switching to the eGPU with the script is only the best when using an external display connected to the eGPU. The DRI_PRIME=1 environment variable is the preferred method for using the eGPU on the laptop's internal display.

For this combination of using the eGPU with open source drivers (amdgpu, i915 or nouveau), but with no display connected to the eGPU you should not switch to the "eGPU mode" of the script. Instead let it use the "internal mode" and use the environment variable DRI_PRIME=1 or a similar method to offload rendering to the eGPU. This can be added to /etc/environment or as a prefix before any command to run it on the eGPU.

If you force Xorg to run on the eGPU with the --override command, with an AMD card I find that even if you get an X session running (I'm able to switch to a TTY and use startx -- to get X running) it will be extremely laggy and unusable so that's why this is not recommended.

@hertg I've used the new golang version of the script and it works well and as expected for me. For the remove command, I wouldn't worry about adding it unless there's a lot of people asking for it. Since I originally added that part of the script things have changed on the driver side and now it's unnecessary for me. With an AMD card on the latest kernel and GNOME desktops I can simply log out, turn off any displays connected to the eGPU and unplug the eGPU. So unless there's someone that needs it, I don't think it's necessary to add that functionality to the script anymore.

from egpu-switcher.

hertg avatar hertg commented on July 21, 2024

Thanks for the report, unfortunately I'm not really familiar with that particular issue (how to handle the situation of using a non NVIDIA GPU with no monitors attached). The original --override flag came from @ewagner12, so they probably have some more valuable information about what is happening here?

@ewagner12 just a sidenote, I have rewritten egpu-switcher in golang last year, but have made my best efforts to port your contributions 1:1 without changing their behaviors, with the exception of the remove feature, which I tried to port but simply wasn't able to get to work.

The source code for the --override flag is here:

egpu-switcher/cmd/switch.go

Lines 127 to 143 in 13b8a06

if driver != "nvidia" {
outputs, err := gpu.Outputs()
if err != nil {
return err
}
connectedOutputs, err := gpu.ConnectedOutputs()
if err != nil {
return err
}
if outputs > 0 && connectedOutputs == 0 {
logger.Warn("No eGPU attached display detected with open source drivers. (Of %d eGPU outputs detected) Internal mode and setting DRI_PRIME variable are recommended for this configuration.\n", outputs)
if !override {
return fmt.Errorf("Not setting eGPU mode. Run the command with the '--override' flag to force loading eGPU mode")
}
logger.Debug("-> Overridden: setting eGPU mode")
}
}

from egpu-switcher.

T-X avatar T-X commented on July 21, 2024

Ha! I found a solution / workaround:

  1. Let lightdm login automatically: I added "autologin-user=myuser" to /etc/lightdm.conf

After that DISPLAY=:0 xrandr on VT2 shows meaningful values and detects eDP-1-1. However running DISPLAY=:0 xrandr --output eDP-1-1 --auto still throws the error "xrandr: Configure crtc 5 failed".

  1. On VT2 (Ctrl+Alt+F2) run xrandr through a terminal emulator instead:
DISPLAY=:0 lxterminal -e xrandr --verbose --output eDP-1-1 --auto
  1. Press Ctrl+Alt+F7 to hop into your logged in desktop, which is now also visible on the laptop screen with your eGPU enabled. And without needing a display connected to the eGPU.

I don't know why the LightDM greeter and Xmonad won't enable and use eDP-1-1 by default in such a case. But this workaround is good enough for me now.

from egpu-switcher.

ewagner12 avatar ewagner12 commented on July 21, 2024

Hi @hertg I tested this more on my system and I found one bug potentially causing unintended behavior in the script related to this issue.

If /etc/X11/xorg.conf.d/99-egpu-switcher.conf exists:
Expected Behavior: Running sudo egpu-switcher switch auto in the above case of AMD eGPU connected with no displays removes the X11 conf file.
Actual Behavior: Running sudo egpu-switcher switch auto in the above case only prints an error, /etc/X11/xorg.conf.d/99-egpu-switcher.conf still exists.

I believe that at line 139 in

egpu-switcher/cmd/switch.go

Lines 137 to 153 in 13b8a06

logger.Warn("No eGPU attached display detected with open source drivers. (Of %d eGPU outputs detected) Internal mode and setting DRI_PRIME variable are recommended for this configuration.\n", outputs)
if !override {
return fmt.Errorf("Not setting eGPU mode. Run the command with the '--override' flag to force loading eGPU mode")
}
logger.Debug("-> Overridden: setting eGPU mode")
}
}
nomodesetting = nomodesetting || viper.GetBool("egpu.nomodesetting")
conf := xorg.RenderConf("Device0", driver, gpu.XorgPCIString(), !nomodesetting)
if err := xorg.CreateEgpuFile(x11ConfPath, conf, verbose); err != nil {
return err
}
if post := viper.GetString("hooks.egpu"); post != "" {
if err := runHook(post); err != nil {
logger.Error("egpu hook error: %s", err)
}
should also remove the eGPU file unless the --override is issued. Otherwise the behavior of the switching is inconsistent in this case, as it keeps the file if it previously existed, but doesn't create it if it doesn't exist.

I can't speak to behavior in Xmonad as I don't use it, but I believe this should avoid a black screen unless the --override command is used

from egpu-switcher.

hertg avatar hertg commented on July 21, 2024

@ewagner12 Thanks for your report, that indeed makes sense. I created a new issue #107 for this

from egpu-switcher.

T-X avatar T-X commented on July 21, 2024

I've also opened a ticket on LightDM here. As I noticed that with just a docking station and no eGPU the LightDM greeter uses all available monitors that are routed through the iGPU. However when the eGPU is enabled through the egpu-switcher then LightDM only uses any monitors connected to the eGPU but not the eDP display anymore, as originally reported.

And also as after login configuring the eDP display via xrandr works. And when I use KDE (instead of xmonad, my prefered window manager) with an eGPU enabled then KDE also enables all connected displays by default, including the eDP-1-1 display. Which made me think that maybe LightDM should/could do something different when eGPUs are used.

from egpu-switcher.

Related Issues (20)

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.