Page 1 of 1

[2.0.8 Linux x64] not using dedicated GPU - ubuntu 24.04

Posted: Tue Oct 22, 2024 6:10 pm
by badgerg
This is an FYI for other Linux users who have both integrated (intel) and dedicated (nvidia) graphics.

I noticed that factorio didn't seem to be using my dedicated graphics. The nvidia-smi utility didn't show the factorio process and the game was running slower than expected. My PRIME profile is set to "Nvidia (Performance Mode)" so I think this should pick up the dedicated GPU automatically.

Code: Select all

$ nvidia-smi
Tue Oct 22 18:47:42 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.107.02             Driver Version: 550.107.02     CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| 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 2060 ...    Off |   00000000:01:00.0 Off |                  N/A |
| N/A   60C    P8              3W /   65W |       7MiB /   6144MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A      4632      G   /usr/bin/gnome-shell                            1MiB |
+-----------------------------------------------------------------------------------------+
Setting the following environment as follows fixes this:

Code: Select all

$ cd /opt/games/factorio/bin
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia ./factorio

Code: Select all

$ nvidia-smi
Tue Oct 22 19:04:17 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.107.02             Driver Version: 550.107.02     CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| 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 2060 ...    Off |   00000000:01:00.0 Off |                  N/A |
| N/A   58C    P0             23W /   65W |    3632MiB /   6144MiB |     32%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A      4632      G   /usr/bin/gnome-shell                            1MiB |
|    0   N/A  N/A     14235      G   ./factorio                                   3624MiB |
+-----------------------------------------------------------------------------------------+

Re: [2.0.8 Linux x64] not using dedicated GPU - ubuntu 24.04

Posted: Tue Oct 22, 2024 9:10 pm
by Blue87
I am on Linux 24.04.1 and appear to have the same issue.

Re: [2.0.8 Linux x64] not using dedicated GPU - ubuntu 24.04

Posted: Tue Oct 22, 2024 9:29 pm
by Blue87
Checking "Software & Updates" -> "Additional Drivers" showed I was using a manually installed driver for an RTX 3060.

Installing graphics driver `nvidia-driver-550` and rebooting fixed my issue.

Factorio runs smoothly and `nvidia-smi` shows /bin/x64/factorio.

Re: [2.0.8 Linux x64] not using dedicated GPU - ubuntu 24.04

Posted: Wed Oct 23, 2024 3:05 am
by Gorthunk
I'm also having this issue... but my CPU and GPU are both AMD.

After further testing it's pretty clear that Factorio is for some reason ignoring the dedicated GPU. Setting DRI_PRIME=1 (either when running from terminal or within Steam launch options), disabling secure boot, selecting "run with dedicated GPU," none of the standard solutions I see to resolve general Linux GPU problems seem to help Factorio utilize the GPU. Other games on Steam don't seem to have this problem, though I'm pretty sure the other games I've tested are all running through Proton and/or with Vulkan shaders.

Alright I resolved it. I had to set DRI_PRIME=0 in the launch options.

Re: [2.0.8 Linux x64] not using dedicated GPU - ubuntu 24.04

Posted: Sat Oct 26, 2024 4:27 am
by Senacharim
Having same issue. (Well, similar, nasty screen tearing, which shouldn't happen if vsync is enabled.)

Update to 'nvidia-driver-550' -- no go.

Added 'DRI_PRIME=0 in the launch options.' -- no go.

Started to experimentally sanity check by methodically disable-enable the various graphics options.

Disabled full-screen, and in windowed mode my screen tearing issue was gone!

Re-enabled full-screen, and screen tearing still gone!

Not sure why that fixed it, but after exit and re-launch, the screen tearing issue seems resolved.

Hope this helps somebody.

Edit: NM, issues persists unless I'm in windowed mode. :-(

Re: [2.0.8 Linux x64] not using dedicated GPU - ubuntu 24.04

Posted: Mon Oct 28, 2024 7:38 pm
by Gorthunk
Senacharim wrote: Sat Oct 26, 2024 4:27 am Added 'DRI_PRIME=0 in the launch options.' -- no go.
Did you try "DRI_PRIME=1" ? That's the standard solution I saw for this problem. I don't know why my case required me to set it to 0, since DRI_PRIME=0 should be the default.

I'm on an AMD card and you're on an NVIDIA card(?), which might be the difference.

Re: [2.0.8 Linux x64] not using dedicated GPU - ubuntu 24.04

Posted: Tue Oct 29, 2024 1:49 pm
by Senacharim
Did you try "DRI_PRIME=1" ? That's the standard solution I saw for this problem. I don't know why my case required me to set it to 0, since DRI_PRIME=0 should be the default.

I'm on an AMD card and you're on an NVIDIA card(?), which might be the difference.
(Now on Factorio 2.0.12)
Tried it, no change in graphical woes. Thank you though.