Unable to use Nvidia GPU with Godot 4.3 under Linux

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 |
+-----------------------------------------------------------------------------------------+
1 Like