I enabled the new "NVIDIA On-Demand" option in the NVIDIA X Server Settings. Now everything uses the iGPU by default, which should be better for battery life (at least, that's what I'm hoping for).
I'd like some applications (like Blender, for example) to use the dGPU by default.
According to the documentation:
To configure a graphics application to be offloaded to the NVIDIA GPU screen, set the environment variable
1. If the graphics application uses Vulkan or EGL, that should be all that is needed. If the graphics application uses GLX, then also set the environment variable
nvidia, so that GLVND loads the NVIDIA GLX driver.
So I just created a shell script to act as a proxy to the Blender executable:
#!/usr/bin/env bash export __NV_PRIME_RENDER_OFFLOAD=1 export __GLX_VENDOR_LIBRARY_NAME=nvidia blender="$HOME/opt/blender-2.82a-linux64/blender" exec -a "$0" "$blender" "$@"
This works fine, but it isn't a particularly clean solution.
The NVIDIA settings have an "Application Profiles" section where you can add application-specific profiles.
(Application profiles documentation)
There are all kinds of OpenGL-related options, but I couldn't find any setting to select which GPU is used. Is this not possible using the application profiles? Is there a cleaner alternative to the environment variables?