In the last post I made about nVidia Prime, I mentioned that the support for nVidia Prime had improved in the new LTS release of Ubuntu, 20.04, as well as downstream relatives, like the upcoming Mint 20. I got Prime offloading working in Neon (currently based on 18.04), but it was not quite as polished as on Ubuntu 20.04. I wanted to get it working the same way, and I was trying to do that when I did the stuff that I mentioned in the previous post, but I’d failed. Now, I’ve succeeded, and this is how!
First of all, the basic package that does the work of switching from one GPU to another is nvidia-prime on Ubuntu. This is developed by Ubuntu themselves, though it has been ported (and in some ways, improved upon, from what I’ve read) to Arch also. I don’t know how well it works, or if it does, on other distros.
The standard nVidia settings application (I think the Windows version is called nVidia Control Panel) recognizes nvidia-prime and provides a convenient front-end for it. For Ubuntu 18.04 and derivatives, the dialog has two radio buttons, for Intel and nVidia. After changing the GPU, the nVidia application advises rebooting, which is kind of inconvenient to switch GPUs, but the Prime Indicator Plus package from WebUpd8 Team improves upon this, allowing you to select “quick switch” from the tray icon, which only requires a logout/in rather than a full reboot (though I had to log out twice to enable nVidia mode previously).
Ubuntu improved the nvidia-prime package for 20.04 to make use of the new Prime offloading mode. It was still possible to have it work in 18.04 with the 18.04 version of nvidia-prime, but switching from the old mode (where you picked one GPU and stuck with it until you changed it manually) was more fiddly. With the new 20.04 version of nvidia-prime, there are three choices… the same Intel and nVidia options as before, but also a new option, on-demand.
On-demand is just an easy way of selecting the offloading mode, where the Intel GPU is used most of the time, but where the nVidia can be selected for any given program at will. There are reasons you might want to select one of the other two modes, Intel or nVidia… the Intel mode is slightly better on power consumption than using Intel in the on-demand mode (for now; hopefully nVidia keeps moving forward on this), and the nVidia mode is necessary if you want to use the external HDMI or DisplayPort on most Optimus/Prime laptops. The external ports are usually wired directly to the nVidia card, so the Intel cannot use them, including in on-demand mode.
I’d probably have switched temporarily to Kubuntu 20.04 as my main OS if KDE Connect had worked (Neon will switch to a 20.04 base probably in the fall, at which time I would likely switch back to Neon). I’ve been installing more and more bits of 20.04 in my Neon, including by now Xorg, the Xorg drivers, the 5.4 kernel, and now the 20.04 versions of nvidia-prime and the one crucial bit I was missing before when I failed to get on-demand working in Neon: the 20.04 version of ubuntu-drivers, common, which contains a small but important program called gpu-manager. Without that, nothing I did could make on-demand work.
With gpu-manager updated, on-demand now works on my Neon installation. I can just edit the shortcuts (.desktop file type) in the application folder to make any program use the nVidia GPU instead of the Intel. It’s not as slick as in Windows, where it switches by itself when it senses the need, but I know which programs are going to benefit from the nVidia GPU and which won’t. I’d set it up this way even in Windows (it is an option there, I seem to recall).
Dell XPS 13/9310, i5-1135G7/16GB, KDE Neon 6.2
XPG Xenia 15, i7-9750H/32GB & GTX1660ti, Kubuntu 24.04
Acer Swift Go 14, i5-1335U/16GB, Kubuntu 24.04 (and Win 11)