Nvidia-prime how-to


I’ve recently acquired a shiny new Dell XPS with both an Intel GPU and an Nvidia GTX 1650.
I installed kubuntu 20.10 and by following some tutorials, I was able to make prime work, and it seems like everything uses the Intel GPU until I manually offload some stuff on the Nvidia one by setting environment variable.

The thing is, I’m not sure about what I’m doing and my search for documentation yielded this page Chapter 35. PRIME Render Offload (which describes the Xorg conf and the aforementioned variables) and next to nothing more.

So I have a few questions now:

The package nvidia-prime provides the four following scripts:

I have no idea what prime-offload and prime-switch are supposed to do. Any idea?

prime-select is the only one somewhat documented, and is apparently doing the same thing as the toggle in the nvidia-settings application PRIME profile. I guess I understand what it does:
intel: Nvidia GPU completely off
nvidia: Nvidia GPU renders everything
on-demand: Nvidia GPU renders Xorg and processes launched with the env variables (according to nvidia-smi)

Although when I used this Xorg.conf file: dell-xps-9570-ubuntu-respin/10-prime-offload.conf at master · JackHack96/dell-xps-9570-ubuntu-respin · GitHub , which is using the configuration mentioned in the doc above, prime-select nvidia behaved the same as on-demand.
Is a xorg.conf file even needed anymore? It seems to work fine without.

I’d really like to understand how all this works. Thanks for the help.




There’s also now the output sink feature (new), but I don’t know about a documentation for it.


Thanks for the links, but I’ve already read most of them, and none of those document what prime-switch or prime-offload do.

They are shell scripts written by Canonical.
They don’t do much else then what is described in the docs.

For example: prime-switch only calls the gpu-manager:
# Call the GPU manager
/usr/bin/gpu-manager --log /var/log/gpu-manager-switch.log
# Give udev the time to add back the drm device
/sbin/udevadm settle --timeout=2
exit 0