Monday, 4 May 2020

Dual-GPU support: Launch on the discrete GPU automatically

*reality TV show deep voice guy*

In 2016, we added a way to launch apps on the discrete GPU.

*swoosh effects*

In 2019, we added a way for that to work with the NVidia drivers.

*explosions*

In 2020, we're adding a way for applications to launch automatically on the discrete GPU.

*fast cuts of loads of applications being launched and quiet*




Introducing the (badly-named-but-if-you-can-come-up-with-a-better-name-youre-ready-for-computers) “PrefersNonDefaultGPU” desktop entry key.

From the specifications website:
If true, the application prefers to be run on a more powerful discrete GPU if available, which we describe as “a GPU other than the default one” in this spec to avoid the need to define what a discrete GPU is and in which cases it might be considered more powerful than the default GPU. This key is only a hint and support might not be present depending on the implementation. 
And support for that key is coming to GNOME Shell soon.

TL;DR

Add “PrefersNonDefaultGPU=true” to your application's .desktop file if it can benefit from being run on a more powerful GPU.

We've also added a switcherooctl command to recent versions of switcheroo-control so you can launch your apps on the right GPU from your scripts and tweaks.

10 comments:

Frédéric Boulet said...

Hi,
Do you believe that this could also be used so that gnome-shell itself uses the dedicated GPU instead of the default one?

Chromiumbook User said...

Will there be some kind of conditional option for whether the system is on battery or AC power?

Thaodan said...

Is this an extension to the Freedesktop.org spec? If not shouldn't it be X-GNOME-PrefersNonDefaultGPU?

Bastien Nocera said...

> Do you believe that this could also be used so that gnome-shell itself uses the dedicated GPU instead of the default one?

No, that's not what it's designed for.

Bastien Nocera said...

> Will there be some kind of conditional option for whether the system is on battery or AC power?

That's not planned.

Bastien Nocera said...

> Is this an extension to the Freedesktop.org spec? If not shouldn't it be X-GNOME-PrefersNonDefaultGPU?

You should consider reading the post a second time...

Ole Laursen said...

PrefersFastestGPU?

Do I win a cake?

"Non default" hardcodes the assumption that the slower GPU is default.

Bastien Nocera said...

> PrefersFastestGPU?

Unfold the threads in that merge request, and see the options that were already discussed. You can't call it "fastest GPU" because you don't know whether it will be the fastest GPU... You win nothing :)

Tomas Janousek said...

It's a bit disappointing that your post omits the important fact that this only works if your primary X server is configured to load the nvidia driver, which is a setup most people don't have, because it usually means the dedicated GPU will consume battery power all the time, rendering this whole "run only select apps on it" idea moot.

Sure, if you have the latest generation of nvidia hardware, then it might just work (http://us.download.nvidia.com/XFree86/Linux-x86_64/440.82/README/dynamicpowermanagement.html, “This feature requires a Turing or newer GPU.”). Many people, however, use bumblebee, bbswitch, nvidia-xrun or some combination of these to achieve acceptable battery life. For them, the feature you described will not work at all.

Bastien Nocera said...

> It's a bit disappointing that your post omits the important fact that this only works if your primary X server is configured to load the nvidia driver

There's a fair number of systems where it works and that don't use the NVidia driver, such as Intel+Radeon or Radeon APU+Radeon GPU, or setups with NVidia cards but using the nouveau driver.

If you think the NVidia drivers don't work well, or well enough, you should definitely bring that with them. I have no power over that, nor do I claim that the little of amount of code I wrote supports all the different use cases. Figuring out how to make NVidia cards use less power is definitely not in my remit, and downgrading to X11 is definitely not in my plans either ;)