The question
Sometimes, applications feel like they're rendering slowly. I don't know which of the multiple GPUs is doing the work for that specific application. I would like to know which GPU is rendering a window or application. How do I find this out on a per-window or per-process basis?
System information
My desktop is running Ubuntu 23.10 on an Intel Skull Canyon NUC. It contains a weird CPU/GPU hybrid with Intel CPU and AMD GPU, on the same die.
alan@nuc:~$ lscpu | grep Model\ name
Model name: Intel(R) Core(TM) i7-8809G CPU @ 3.10GHz
alan@nuc:~$ lspci | grep AMD
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI]
Polaris 22 XT [Radeon RX Vega M GH] (rev c0)
I also have an external GPU in a thunderbolt enclosure.
alan@nuc:~$ lspci | grep GeForce
40:00.0 VGA compatible controller: NVIDIA Corporation
TU102 [GeForce RTX 2080 Ti Rev. A] (rev a1)
I have three 1080p displays attached to the NVIDIA 2080 Ti. No displays are connected to the internal HDMI or DisplayPort connectors.
alan@nuc:~$ xrandr | grep "*"
1920x1080 60.00*+ 59.99 59.94 50.00
1920x1080 60.00*+ 59.94 50.00 29.97
1920x1080 60.00*+ 59.99 59.94 50.00
I am running the latest version of the Nvidia driver.
alan@nuc:~$ lsmod | grep ^nvidia\
nvidia 56811520 920 nvidia_uvm,nvidia_modeset
alan@nuc:~$ modinfo nvidia | grep ^version
version: 535.161.07
alan@nuc:~$ dpkg -l nvidia-driver* | grep ^ii
ii nvidia-driver-535 535.161.07-0ubuntu0.23.10.1 amd64
NVIDIA driver metapackage
Edit: Adding this thanks to the answer below from Alistair Buxton. Interesting that the AMD GPU is the "Default" (which I suspect isn't what I want).
So the answer is I need to use switcheroo launch
or launch using GNOME application launcher.
alan@nuc:~$ switcherooctl list
Device: 0
Name: Advanced Micro Devices, Inc. [AMD®/ATI] Polaris 22 XT [Radeon RX Vega M GH]
Default: yes
Environment: DRI_PRIME=pci-0000_01_00_0
Device: 1
Name: NVIDIA Corporation TU102 [GeForce RTX 2080 Ti Rev. A]
Default: no
Environment: __GLX_VENDOR_LIBRARY_NAME=nvidia __NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only
My workflow
I typically launch applications from their icon in the GNOME Shell launcher or from a shell script I manually run, which launches all my desktop applications on startup. However, there's also the option in the launcher to "Launch using Integrated Graphics Card".
For example, here's the standard Steam launcher icon menu:
The problem
Sometimes, I feel like applications are rendering slowly.
Restating the question
I'd like to know how I know which GPU is in use by a process or window.
Happy to hear other opinions like:
- You're seeing things
- It's the thunderbolt which is slow
Not inclined to do any of these: :)
- Use Wayland
- Use the open source nouveau driver
- Remove the NVidia GPU
Run
switcherooctl list
and you will see output like this for each GPU:Note the environment section. Gnome Shell launches programs with
switcherooctl launch
, which just inserts those variables into the program's environment. So when you want to determine which GPU a program is running on, check/proc/$pid/environ
for environment variables matching one of the devices in the list.Edit to add: my understanding is that Gnome only uses switcheroo if you explicitly choose one of the "integrated" or "discrete" options. Otherwise it just runs the program normally. You won't see either set of variables in the environment, and absent any other config, the program will be running on whichever GPU your monitor is connected to.
But do note I don't use either Gnome or a dual GPU set up so I could be wrong about this.
You can verify that
switcheroo launch
works for a particular card by using it to launchglxgears -info
and checking the value ofGLX_RENDERER
at the top of the output.