flathub / org.blender.Blender

https://flathub.org/apps/details/org.blender.Blender
18 stars 26 forks source link

Blender viewport not working with nVidia optimus correctly #120

Open jkms opened 2 years ago

jkms commented 2 years ago

When I launch Blender via Flatpak on my nVidia Optimus laptop Blender correctly detects my nVidia card and it's CUDA abilities, but it doesn't actually use the nVidia GPU for rendering the viewport (notice that there's nothing in the output of nvidia-smi in the first screenshot):

If I try to manually start blender with the Optimus/Prime environment variables:

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia flatpak run org.blender.Blender 
Read prefs: /home/john/.var/app/org.blender.Blender/config/blender/3.2/config/userpref.blend
Error! Unsupported graphics card or driver.
A graphics card and driver with support for OpenGL 3.3 or higher is required.
The program will now close.

However, when I start the non-flatpak version, it works correctly:

__NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia ./blender 
Read prefs: /home/john/.config/blender/3.2/config/userpref.blend
/run/user/1000/gvfs/ non-existent directory
Saved session recovery to '/tmp/quit.blend'

Blender quit # this is just me closing the window

Flatpak

Like I said, blender flatpak works, and it sees my nVidia card: image

Notice the GPU usage on my radeon iGPU vs the nVidia GPU. image

Non-flatpak

However, when running the non-flatpak version with the Optimus/Prime env variables, I get buttery smooth performance, and the viewport rendering is offloaded to my nVidia card: image

Is this a bug? or missing how to launch the flatpak correctly so that the viewport will use my nVidia GPU?

Martin15135215 commented 1 year ago

I had this solution from this answer

In Short: Run this command

flatpak override --user --device=dri --env=__NV_PRIME_RENDER_OFFLOAD=1 --env=__VK_LAYER_NV_optimus=NVIDIA_only --env=__GLX_VENDOR_LIBRARY_NAME=nvidia org.blender.Blender

However, Cuda did not function for me :(