I’m STRUGGLING a bit with my Nivida GPU attachment. I’m running Arch newest everything, and for the life of me I can’t get the NVIDIA GPU to shut down when on battery. I feel like I’ve tried everything on the Arch Linux wiki and it still refuses to shut down.
This leads to a a usage of 20-30W on battery which drains the battery in about 2 hours (if I’m lucky).
I can use EnvyControl to disable the dGPU until reboot, which is quite annoying process. However with the dGPU disabled my usage drops to 9-13W, which is what is expected.
I don’t know what you’ve tried or how you’re testing this, but I’ve got a few tips. Note though, that I have the RX 7700s module, not the 5070. I used to have a Razer laptop running Arch with a 3070 though.
Don’t use tools like nvtop to check whether the dGPU is on or not. These tools wake the device up and they themselves will prevent the dGPU from turning on. It’s better to run a command like cat /sys/class/drm/card1/device/power_state and check to see if the dGPU is in D0 (on) or d3Cold (off). This doesn’t wake the dGPU.
Some apps (e.g. Discord, Steam, some web browsers) will turn the dGPU on for a moment but then it will re-enter sleep on it’s own. If you have a tool running that’s watching for dGPU activity, when these other apps turn on the dGPU, that measurement tool could then latch onto it and prevent it from turning on. For example, I have modified the firmware on my keyboard to turn one of the lights red when the dGPU is on. When the dGPU is on, I have to change the sampling rate so that I don’t accidentally keep it on through the act of observing it. RGB Keyboard Custom Firmware - PC Utilization Stats
You can use nvtop to figure out which processes are binding to the dGPU, and then configure the env variables/launch options for that application to prefer a given GPU. For example, these env variables I use when I want to force an app onto the iGPU.
Technically, only DRI_PRIME or the filter variable should be needed, but I like to be certain.
You can get the name needed by the filter variable with vulkaninfo e.g., vulkaninfo | grep 5070
If those don’t work, you can also try loading the game with gamescope and making use of it’s --perfer-vk-device parameter. Unfortunately, I’ve deleted my sample of that command though.
If you’re trying to run an application/game with mangohud and on the iGPU, you’ll need to toggle mangohud off temporarily. I’ve noticed that if I successfully launch a game on the iGPU with mangohud running, mangohud will latch onto the dGPU rather than the GPU in use and then mangohud itself will report the dGPU’s stats and keep the dGPU online. I can get around this by hitting shift + f12 to toggle the overlay off, wait ~10 seconds, then turn it back on.
That’s all I can think of off the top of my head. I’ll make another comment if I think of more.
Is there a piece of software that checks whether the dGPU is asleep without waking the dGPU itself?
I use btop on a laptop (not a Framework) with Nvidia GPU, if btop starts immediately, the Nvidia dGPU is awake, if btop needs half a second to start, the GPU was asleep and btopwoke it, I’ll then turn off btop and the Nvidia dGPU will sleep within 10 seconds.
The only 2 reliable ways I’ve found to do it are A) the cat command I cited above, and B) the custom keyboard firmware I developed, as I wrote it with that feature specifically in mind.
I have a simple script in my home folder called gpu_state.sh that checks the state of both GPUs.
Using NVTOP that is the only entry using the Nvidia card. Also why is my dGPU device Zero and not 1? Regardless, I’m not sure why this is forcing it on.
I think that was how I may have resolved it as well, but I thought you said you were on the latest? IIRC both Gnome and Plasma have done away with X11.
Sorry for kinda hijacking this thread, but I have a question regarding the same topic:
I want to use only my iGPU instead of dGPU for a certain game. (Slay the Spire 2)
I tried everything in step 3., my commandline for the game in steam looks like this: MESA_VK_DEVICE_SELECT=1002:15bf! DRI_PRIME=0 DXVK_FILTER_DEVICE_NAME=“AMD Radeon 780M Graphics (RADV PHOENIX)” %command%
But still, the game is primarily using the iGPU, but still somehow latches onto the dGPU thus keeping it awake…
I know that because the power usage isnt ~20W but ~60W, cat /sys/class/drm/card1/device/power_state= D0 and amdgpu_top shows this:
Temporary solution would be to force iGPU only one start up.
But for now you probably should first confirm the dgpu is running Slay but running nvtop as you run the program and see if it says GPU 1. If not, check to see if its another program running it.
Thank you, that gave me the idea that led to a solution!
I checked all possible culprits and think I managed to configure it the way I want:
Discord wakes up the dGPU twice on startup
Steam wakes up the dGPU on startup and for some time afterwards, unless I tab into other windows
Waiting for Steam to stop waking up the dGPU and only then Slay the Spire 2 uses only the iGPU (with MESA_VK_DEVICE_SELECT=1002:15bf! %command% )!
Now I only wonder how I can force Steam to never wake up the dGPU at all, because then I should be able to start any game using only the iGPU…
The difference is huge: If I play StS2 with the dGPU I get maybe 45 minutes of playtime with lowest display brightness, CPU clocks and WIFI turned off. But with the iGPU I can watch a stream at the same time with a bright display and still get ~2 hours