11

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 __NV_PRIME_RENDER_OFFLOAD to 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 __GLX_VENDOR_LIBRARY_NAME to 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:

~/.local/bin/blender

#!/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?

tttapa
  • 428
  • 4
  • 13
  • This worked for you? trying something similar gave me a blender that can't detect CUDA. – nbubis Nov 04 '20 at 21:18
  • @nbubis yes this works for me. The script I posted only selects the GPU used for rendering the UI and the 3D scene editor etc. The actual Cycles rendering doesn't use the standard graphics API but custom CUDA code, it is independent of the `__NV_PRIME_RENDER_OFFLOAD` and `__GLX_VENDOR_LIBRARY_NAME` variables. If Blender doesn't detect your GPU as a CUDA device, that probably means you haven't installed your NVIDIA graphics drivers correctly. – tttapa Jan 05 '21 at 20:57

1 Answers1

0

What worked for me is adding these lines in the .desktop files of the applications I want to use the dgpu by default.

PrefersNonDefaultGPU=true
X-KDE-RunOnDiscreteGpu=true

What it also does is replace the launch using dedicated graphics option with the launch using integrated graphics option. This works on ubuntu 22.04, I'm not sure about backwards compatibility but I believe it should work on impish, focal, and bionic as well.