Unable to use Nvidia GPU with Godot 4.3 under Linux

Godot Version

v4.3.stable.flathub.77dcf97d8

Question

I have Godot 4.3 installed as a Flatpak on Tuxedo OS 3. I have a dedicated GPU from Nvidia (RTX 3050 Ti laptop).

When I have the Nvidia card enabled, Godot still uses the integrated Intel GPU. Other programs are able to use the Nvidia card (Blender, running games through Steam etc.).

I was made aware of this thread where a couple of strategies were mentioned:

  1. Calling Godot with the --gpu-index argument. The output from flatpak run org.godotenegine.Godot --gpu-index 0:
Godot Engine v4.3.stable.flathub.77dcf97d8 - https://godotengine.org
glx: failed to create dri3 screen
failed to load driver: nouveau
OpenGL API 4.6 (Core Profile) Mesa 24.1.3 (git-0c49f54c76) - Compatibility - Using Device: Intel - Mesa Intel(R) Graphics (ADL GT2)

Editing project: /path/to/project
Godot Engine v4.3.stable.flathub.77dcf97d8 - https://godotengine.org
Vulkan 1.3.278 - Forward+ - Using Device #0: Intel - Intel(R) Graphics (ADL GT2)

It seems it tries to use the noveau driver instead of the proprietary drivers I have installed (I believe noveau is blacklisted when the proprietary drivers are installed?). It also seems to start with OpenGL and switch over to Vulkan after opening a project.

Choosing --gpu-index 1 resulted in very laggy performance and llvmpipe was listed in the console instead of the Intel GPU upon running the project. My guess is that this means it runs on the CPU instead?

  1. The second suggestion was to right-click the desktop entry and click “Run with discrete GPU” when in on-demand mode. This results in the same fallback to the Intel GPU.

Any suggestions for how I can fix this? It was suggested to remove noveau, but I’m a little scared to just do that… :slight_smile:

Does blender run through flatpak? Have you tried godot as a executable or built from source instead?

You should only have the one nvidia driver installed, it’s probably a good idea to remove nouveau, debian-based distros will blacklist/disable nouveau if nvidia-driver is installed but I’m guessing flatpak is seeing nouveau and installing packages for that.

Install flatseal and check if godot has permission to access gpu.

1 Like

I use Godot with an Nvidia GPU under Linux and have never run into a problem, although I don’t think I have the nouveau drivers on my system at all. I also download Godot from the website rather than using flatpak, not sure if that makes a difference.

There is a program Optimus Manager that can force the use of dedicated gpu.

I had this problem and I found that the prime-run script does not work well with flatpaks.

What made this work for me was to enter the env variables to the flatpak which the prime-script does for you. I expect the problem is something to do with the way flatpaks are launched – but you can see what the prime-run helper script does by looking at the file at /usr/bin/prime-run – All it is doing is passing in these env variables:
__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia

Use Flatseal to add them, and also give permission to access GPU:

[Couldn’t show other screenshot due to embedded media limit on new users]

After doing this, you can verify it is working with nvidia-smi - eg:

 max@laptop ~  nvidia-smi
Wed Sep 11 23:00:54 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 560.35.03              Driver Version: 560.35.03      CUDA Version: 12.6     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 3050 ...    Off |   00000000:F3:00.0 Off |                  N/A |
| N/A   41C    P8              3W /   10W |      60MiB /   4096MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A     33346      G   /app/bin/godot-bin                             54MiB |
+-----------------------------------------------------------------------------------------+