Is this a problem with the drivers or just my iGPU?

I have an AMD + NVIDIA laptop (Acer Nitro AN515-43 Ryzen 7 3750H GTX 1650) and I’m currently trying to get the drivers to work, this is what I’ve set so far on the configuration.nix:

#nvidia 
  hardware.graphics = {
    enable = true;
    enable32Bit = true;
    extraPackages = with pkgs; [nvidia-vaapi-driver];
  };
  
   hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;
   services.xserver.videoDrivers = ["nvidia"];
   hardware.nvidia.open = true;
   hardware.nvidia.modesetting.enable = true;

   hardware.nvidia.prime = {
    sync.enable = true;

    # integrated
    amdgpuBusId = "PCI:5:0:0";
    # dedicated
    nvidiaBusId = "PCI:1:0:0";
  };

while it seems that indeed my graphics card is detected (even tho it doesn’t list it on the about system) the applications seem to be defaulting to the AMD iGPU instead (tested it with Prism Launcher for Minecraft, I could force it to run with the discrete GPU tweak but it’s clearly not optimal and I’m not sure if this can be done for steam as well)

is this a matter of having installed the drivers incorrectly (which, I honestly kinda feel I did) or it’s just a matter of making the NVIDIA GPU a priority instead of the AMD iGPU? I have no worries about power consumption since laptop is always plugged if this is important.

Your configuration is correct, but the upstream module currently only supports X11, while most desktops have moved on to wayland at this point.

Assuming you’re on a wayland desktop, that config effectively does nothing (besides maybe for xwayland, I haven’t fully figured that aspect out yet). What WM/DE do you use?

The rest of your config also falls a bit short, the vaapi-driver won’t do much without some env vars. But if you have an iGPU, it’s typically better to use it for media en/decoding. NVIDIA does not officially support this type of hardware acceleration on Linux, so use the amd vaapi driver (consult the wiki for details).

You should also set powermanagement.enable because its name is terrible and it’s actually a memory manager for suspend, and has nothing to do with energy efficiency.

Using dynamicBoost can also still help, I think, but consult the nvidia docs.

I’m on GNOME and Wayland yes

so, I don’t think I’ve understood from this message alone but, what should I remove from the config and add?

Right, I was asking you what DE you’re on so I can give you an answer :slight_smile:

I don’t use GNOME, so YMMV, but given their documentation, your configuration, and some magic I’ve put together previously:

services.udev.extraRules = let
  nvidiaId = map (i: lib.toHexString (lib.toInt i)) (
    lib.drop 1 (lib.splitString ":" config.hardware.nvidia.prime.nvidiaBusId)
  );
  domain = "0000";
  bus = builtins.elemAt nvidiaId 0;
  device = builtins.elemAt nvidiaId 1;
  function = builtins.elemAt nvidiaId 2;
in ''
  SUBSYSTEM=="drm", ENV{DEVTYPE}=="drm_minor", ENV{DEVLINKS}=="/dev/dri/by-path/pci-${domain}:${bus}:${device}.${function}", TAG+="mutter-device-preferred-primary"
'';

This will also require a reboot.

Not that I’ve tested this, it’s quite possible the udev rule doesn’t trigger on DEVLINKS early enough or something. If that doesn’t work, follow the GNOME docs - if it does work, please tell me, because this’d be super handy to upstream in some form so you don’t need to do it :slight_smile:

As for the other details, you should also at least set hardware.nvidia.powermanagement.enable, and remove this line:

    extraPackages = with pkgs; [nvidia-vaapi-driver];

… and also, if the snippet for setting the primary GPU doesn’t work and you’re up for some ad-hoc debugging to help future users, send me a dm :wink:

Okay, I’ve removed the vaapi-driver and set hardware.nvidia.powermanagement.enable but I feel maybe I pasted the above thing wrong (decided to paste it at the end of the NVIDIA session I made) cause upon trying to rebuild the system I got this following error:

error:
       … while evaluating the attribute 'config.system.build.toplevel'
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:12322:
       … while calling the 'seq' builtin
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:12331:
       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: undefined variable 'lib'
       at /etc/nixos/configuration.nix:157:22:
          156|   services.udev.extraRules = let
          157|   nvidiaId = map (i: lib.toHexString (lib.toInt i)) (
             |                      ^
          158|     lib.drop 1 (lib.splitString ":" config.hardware.nvidia.prime.nvidiaBusId)

also, I feel I’d be up to help future users but I don’t know what I could be of much help with honestly

Right, at the top of your config you’ll see something like:

{ config, pkgs, ... }:

Add lib to it:

{ config, pkgs, lib, ... }:

… as well as config if it isn’t there yet.

added the lib on the config top. but now for some reason it is telling me that
hardware.nvidia.powermanagement.enable does not exist.

error:
       … while evaluating the attribute 'config.system.build.toplevel'
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:12322:
       … while calling the 'seq' builtin
         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:12331:
       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: The option `hardware.nvidia.powermanagement' does not exist. Definition values:
       - In `/etc/nixos/configuration.nix':
           {
             enable = true;
           }

And it’d be right, that’s a typo on my end: hardware.nvidia.powerManagement

lol, okay, I’ve rebuilt the config and it went all right, restarted the laptop but, the dGPU is still not being detected.
doesn’t appear on the system about, and is also not detected by prism launcher (minecraft launcher) and steam system info. I dunno if it would be of help but, since I’ve read some threads before that some people ran this, here is what appears after I run nvidia-smi

+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 565.77                 Driver Version: 565.77         CUDA Version: 12.7     |
|-----------------------------------------+------------------------+----------------------+
| 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 GTX 1650        Off |   00000000:01:00.0 Off |                  N/A |
| N/A   47C    P8              3W /   50W |       3MiB /   4096MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A      2189      G   ...aa-gnome-shell-47.2/bin/gnome-shell          1MiB |
+-----------------------------------------------------------------------------------------+

Yes, that does give us a lot of useful information.

This section lists everything running on the GPU. As you see, gnome-shell is running on it, which means that GNOME is being rendered with your dGPU - looks like it’s working?

Do other processes appear in there when you start them? Both the applications you’re talking about are using Xwayland AIUI; what about your browser or some native gtk4 applications?

Are you using flatpak?

is that so? I thought that the “off” meant that it wasn’t working.

I’m not using flatpak, also can’t seem to find any processes related to NVIDIA on the system monitor if that’s what you talking about (or I could also just don’t know where to check too honestly)

No, admittedly the info is hard to read, especially in a small terminal window. If you read the headings carefully, it’s this one:

… which won’t tell you much if you don’t know much about the driver.

It refers to persistence mode, which can help keep the GPU state “fresh” if you’re running it headless in a datacenter to run CUDA operations. On desktop systems It’s pointless if it’s your primary GPU, since it will never be turned off, and if it’s your secondary GPU it’s actively harmful, since it prevents the GPU going into the lowest power state.

So, the off there basically refers to an enterprise feature that should be off.

This is what that output looks like on my offload system, where the dGPU isn’t currently used at all - note that running nvidia-smi itself will cause that 4% load and the little bit of memory usage; normally the GPU is turned off entirely (with powermanagement.finegrained.enable), it even takes a few seconds for it to start up in response to nvidia-smi:

+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.133.07             Driver Version: 570.133.07     CUDA Version: 12.8     |
|-----------------------------------------+------------------------+----------------------+
| 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 RTX A500 Laptop GPU     Off |   00000000:01:00.0 Off |                  N/A |
| N/A   34C    P3              8W /   35W |       1MiB /   4096MiB |      4%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

No, I mean, if you’re running literally anything in addition to just the GNOME desktop, does it turn up in the list in nvidia-smi?

I guess not, because your terminal should probably be in there too, but perhaps you’re using the gnome-shell built-in terminal.

To put it plainly, can you start up Firefox (asking for specifically that browser because I think it’s the only one that reliably actually supports wayland) and check if it turns up in the nvidia-smi output?

And then repeat that experiment with prismlauncher running?

decided to give it a try and have some interesting findings

so, when I opened firefox and ran nvidia-smi nothing showed up in processes as shown here:

Mon May 12 16:58:59 2025       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 565.77                 Driver Version: 565.77         CUDA Version: 12.7     |
|-----------------------------------------+------------------------+----------------------+
| 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 GTX 1650        Off |   00000000:01:00.0 Off |                  N/A |
| N/A   43C    P8              2W /   50W |       3MiB /   4096MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A      8266      G   ...aa-gnome-shell-47.2/bin/gnome-shell          1MiB |
+-----------------------------------------------------------------------------------------+

and, the same has happened with prislauncher running minecraft

Mon May 12 16:58:59 2025       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 565.77                 Driver Version: 565.77         CUDA Version: 12.7     |
|-----------------------------------------+------------------------+----------------------+
| 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 GTX 1650        Off |   00000000:01:00.0 Off |                  N/A |
| N/A   43C    P8              2W /   50W |       3MiB /   4096MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A      8266      G   ...aa-gnome-shell-47.2/bin/gnome-shell          1MiB |
+-----------------------------------------------------------------------------------------+

however, I decide to give steam I try, when idling nothing changed from the above, BUT I decided to try giving ELDEN RING a go (probably the most graphically demanding game I own) and, when running it and running nvidia-smi it DID picked it up and showed it in processes:

Mon May 12 17:06:29 2025       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 565.77                 Driver Version: 565.77         CUDA Version: 12.7     |
|-----------------------------------------+------------------------+----------------------+
| 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 GTX 1650        Off |   00000000:01:00.0 Off |                  N/A |
| N/A   51C    P5              5W /   50W |    2406MiB /   4096MiB |      4%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A      8266      G   ...aa-gnome-shell-47.2/bin/gnome-shell          1MiB |
|    0   N/A  N/A     12515    C+G   ...ommon\ELDEN RING\Game\eldenring.exe       2398MiB |
+-----------------------------------------------------------------------------------------+

that’s, interesting, I will probably download more steam games and report back to see if they all appear in the processes or if some don’t, but it’s weird prismlauncher is still not picked up on it (you could force on the tweaks of it to use your dGPU BUT the launcher always seem to crash when I close the game after picking up this option)

after some tests here’s what I found out:
I’ve tested a few games (both with 3D graphics and some with not)
I’ve tested besides ELDEN RING: Dark Souls Remastered, Left 4 Dead 2, ULTRAKILL, Hollow Knight, Terraria, Yakuza Kiwami, A Hat in Time (tried to test this one but it wouldn’t launch, but this is probably cause this game has always not been running good out of the box on Linux for as long as I can remember)
the only games that have not been shown on processes on nvidia-smi were Left 4 Dead 2 and Terraria for some reason (probably the same reason as prismlauncher maybe?)

for prismlauncher I decided to test forcing the dGPU to be used on the tweaks and it was shown on processes but seems the launcher always crashes when using this tweak, although I feel this might be a bug of the launcher rather than something on the dGPU/OS which I will see with their community (and maybe try other launchers too and see what happens)

That’s indeed interesting. Can you try checking if the attribute was correctly applied to your GPU? You can use udevadm for that:

udevadm /dev/dri/card1
udevadm /dev/dri/card2

As far as minecraft goes, the launcher doesn’t really need to run on the dGPU to get Minecraft to do so. If you’re offloading, this is determined by a few environment variables, see these docs (but ignore the xorg config): Chapter 35. PRIME Render Offload

running both commands returned the following:

Unknown command verb '/dev/dri/card1'.

(same thing for /dev/dri/card2 but with card 2 instead)

Sorry, my bad, the command is udevadm info, needs to run as root.