seerge / g-helper

Lightweight Armoury Crate alternative for Asus laptops and ROG Ally. Control tool for ROG Zephyrus G14, G15, G16, M16, Flow X13, Flow X16, TUF, Strix, Scar and other models
https://seerge.github.io/g-helper/
GNU General Public License v3.0
6.97k stars 254 forks source link

[Feature request] Enable / disable dGPU when it should not be active #627

Closed danielrs closed 1 year ago

danielrs commented 1 year ago

First of all let me say thank you for this project! It's hard to believe this didn't exist a couple of months ago.


Is your feature request related to a problem? Please describe.

Sometimes the dGPU will stay active after Advanced Optimus switches cards (from dGPU to iGPU); some apps keep using the dGPU even through they shouldn't. Similar tools already implement fixes for this: https://github.com/BartoszCichecki/LenovoLegionToolkit#deactivate-discrete-nvidia-gpu

Describe the solution you'd like

Implement a way to force stuck apps to move to the iGPU, either by killing them (could be bad); or disabling/enabling the dGPU temporarily (good if no critical process is using it).

Describe alternatives you've considered

I have a small script to do the latter for me:

pnputil /disable-device "PCI\VEN_10DE&DEV_2860&SUBSYS_14731043&REV_A1\4&17526e30&0&0008"
timeout /nobreak /t 3 > NUL
pnputil /enable-device "PCI\VEN_10DE&DEV_2860&SUBSYS_14731043&REV_A1\4&17526e30&0&0008"
timeout /nobreak /t 3 > NUL

Could be nice to have a button (e.g. in the "Extra" window) to do this for us, conditioned by the fact that the dGPU is not driving the display (and other conditions maybe?).

Aashishkebab commented 1 year ago

Would it not be a bad experience to have apps killed because they are using a different GPU? Armoury Crate doesn't kill them either, it just notifies you that these apps are running.

Also is it even possible to move an app already running without killing it or causing issues? Either way, this might be a bad UX, especially if you just accidentally bump the power chord.

seerge commented 1 year ago

@danielrs hello.

Restart GPU (via pnputil) is already in g-helper actually, but app offers to run it only as a last resort if switching to "Eco" mode (i.e. powering dPGU off) is refused by bios on first attempt. This is quite "invasive" operation (windows could BSOD from that even) and I'm not sure if it's a very good idea to add it as a publicly accessible button somewhere in UI :)

But you can manually execute this operation (in powershell as admin)

$device = Get-PnpDevice | Where-Object { $_.FriendlyName -imatch 'NVIDIA' -and $_.Class -eq 'Display' }; Disable-PnpDevice $device.InstanceId -Confirm:$false; Start-Sleep -Seconds 3; Enable-PnpDevice $device.InstanceId -Confirm:$false

Killing apps using GPU is also implemented in the app (under Extra), but it's executed prior to setting "Eco" mode as well (again to help bios to power off GPU)

That button could be added to the UI (it's even in the poll for new features https://github.com/seerge/g-helper/discussions/583 )

danielrs commented 1 year ago

@Aashishkebab I agree with you, but there's some apps that should not be using the dGPU at all but stay stuck using it. Apps such as Xbox Game Bar, Search App, MSEdgeWebView2, etc.

@seerge Thanks for the detailed reply, I didn't know enabling and disabling the dGPU could BSOD. Do you think then a "safer" way to achieve the same thing would be to switch to "Eco" mode through bios, and then back to standard?

Just trying to figure out the best way to get rid of those apps keeping the dGPU awake.

seerge commented 1 year ago

@danielrs

I didn't know enabling and disabling the dGPU could BSOD. Do you think then a "safer" way to achieve the same thing would be to switch to "Eco" mode through bios, and then back to standard?

It is generally safe. But it's my argument to not add it as a part of UI in the app :) (since I managed to get BSOD mb someone else could, and then it's and immediate screaming topic about "g-helper causing BSOD" on reddit)

You can try that, as a method (just run that powershell command or even create a windows shortcut with that command) and see if it works / helps your GPU go to sleep in optimus.

danielrs commented 1 year ago

@seerge Thank you, that makes a lot of sense. I can definitely get behind your desire to keep g-helper stable and reliable. This is easily achievable through a custom command / shortcut.

danielrs commented 1 year ago

We can reopen if we desire to explore this again :)