Issues with nvidia-powerd.service and Optimus PRIME offloading on NixOS

I’m encountering an issue where the nvidia-powerd.service fails to start, and I am unsure whether my Optimus PRIME offloading configuration is working properly on NixOS. I have an Intel and Nvidia GPU setup (Intel UHD 630 and Nvidia GTX 1050 Ti), and I want to enable GPU offloading for performance tasks while using the Intel GPU for less demanding tasks.

System Information:

  • Nvidia GPU: GTX 1050 Ti Mobile (PCI:1:0:0)
  • Intel GPU: UHD Graphics 630 (PCI:0:2:0)
  • Kernel Version: 6.10.9-zen1
  • NixOS Version: 24.11.20240926.1925c60 (Vicuna)

Steps Taken:

  1. I configured my nvidia.nix file to enable Nvidia offloading through Optimus PRIME, using the following setup:

    services.xserver.videoDrivers = ["nvidia"];
    
    hardware.nvidia-container-toolkit.enable = true;
    
    hardware.nvidia = {
      modesetting.enable = true;
      powerManagement.enable = true;
      powerManagement.finegrained = true;
      dynamicBoost.enable = lib.mkForce true;
      nvidiaSettings = true;
      package = config.boot.kernelPackages.nvidiaPackages.production;
    
      prime = {
        offload = {
          enable = true;
          enableOffloadCmd = true;
        };
        nvidiaBusId = "PCI:1:0:0";
        intelBusId = "PCI:0:2:0";
      };
    };
    
  2. I successfully rebuilt my system with sudo nixos-rebuild switch.

  3. After rebooting, I noticed that the nvidia-powerd.service fails to start with the following error in the logs:

    nvidia-powerd.service - nvidia-powerd service
       Loaded: loaded (/etc/systemd/system/nvidia-powerd.service; enabled; preset: enabled)
       Active: failed (Result: exit-code) since Mon 2024-12-02 18:57:41 EET; 268ms ago
       Invocation: 3407735c2e43471e9a1c29c4209082a6
      Process: 149160 ExecStart=/nix/store/xdxyd05p3brlj7s1nsij58kivf7q9lc1-nvidia-x11-550.120-6.10.9-bin/bin/nvidia-powerd (code=exited, status=1/FAILURE)
    

    The logs show:

    Dec 02 18:57:41 nixos /nix/store/xdxyd05p3brlj7s1nsij58kivf7q9lc1-nvidia-x11-550.120-6.10.9-bin/bin/nvidia-powerd[149160]: No matching GPU found
    Dec 02 18:57:41 nixos /nix/store/xdxyd05p3brlj7s1nsij58kivf7q9lc1-nvidia-x11-550.120-6.10.9-bin/bin/nvidia-powerd[149160]: Failed to initialize Dynamic Boost
    Dec 02 18:57:41 nixos systemd[1]: nvidia-powerd.service: Main process exited, code=exited, status=1/FAILURE
    
  4. I have verified the bus IDs for both the Intel and Nvidia GPUs using lspci:

    00:02.0 VGA compatible controller: Intel Corporation CoffeeLake-H GT2 [UHD Graphics 630]
    01:00.0 VGA compatible controller: NVIDIA Corporation GP107M [GeForce GTX 1050 Ti Mobile]
    

    The correct bus IDs are:

    • Intel GPU: PCI:0:2:0
    • Nvidia GPU: PCI:1:0:0

Expected Behavior:

  • The nvidia-powerd.service should start successfully and manage GPU power states without errors.
  • Optimus PRIME offloading should allow me to offload rendering tasks to the Nvidia GPU as needed, while the Intel GPU is used for less demanding tasks.

Actual Behavior:

  • The nvidia-powerd.service fails to start with an error: No matching GPU found.
  • The Optimus PRIME offloading might not be functioning as expected, as I am unsure if the Nvidia GPU is being used for rendering tasks.

What I Have Tried:

  • Disabled nvidia-powerd by setting systemd.services.nvidia-powerd.enable = false; in the configuration, but the issue persists.
  • Verified the correctness of the Bus IDs using lspci, and the configuration matches the actual system.
  • Attempted to test Optimus offloading using prime-run, but I am unsure if it is working as expected.

Logs:

Here are the relevant logs from journalctl:

Dec 02 18:57:41 nixos /nix/store/xdxyd05p3brlj7s1nsij58kivf7q9lc1-nvidia-x11-550.120-6.10.9-bin/bin/nvidia-powerd[149160]: No matching GPU found
Dec 02 18:57:41 nixos systemd[1]: nvidia-powerd.service: Main process exited, code=exited, status=1/FAILURE

Questions:

  1. Has anyone encountered a similar issue with nvidia-powerd.service failing to start?
  2. Does my Optimus PRIME offloading configuration look correct, and how can I test it effectively?
  3. Are there any additional steps I should take to resolve the issue, especially with Nvidia power management?

Any help or insights would be greatly appreciated!


According to the Nvidia docs - Chapter 23. Dynamic Boost on Linux, among the hardware requirements for dynamic boost, the GPU architecture must be Ampere or newer, but your GPU uses Pascal, which is older, so I guess your hardware simply doesn’t support this.

To disable nvidia-powered, you need to remove hardware.nvidia.dynamicBoost.enable.

I don’t think there is a prime-run command. Instead, you should use nvidia-offload, which should be installed in your system since you’ve enabled hardware.nvidia.prime.offload.enableOffloadCmd (See NVIDIA - NixOS Wiki).

Aside from this, your config looks fine to me.

The command is nvidia-offload as already mentioned

You can also try this (seems to be a Xorg syntax…)

    nvidiaBusId = "1@0:0:0";
    intelBusId = "0@2:0:0";

Thank you so much, @marmar and @eljamm!

After disabling DynamicBoost, I used the following configuration:

  • intelBusId = "0@0:2:0"
  • nvidiaBusId = "1@0:0:0"

This adjustment worked flawlessly, and the setup is now running perfectly without any errors. I truly appreciate the assistance!

1 Like