Nvidia-settings and nvidia-offload not found

For info here is the output of nvidia-smi :

$ nvidia-smi 
Fri Mar 22 16:57:25 2024       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.157                Driver Version: 390.157                   |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  NVS 4200M           Off  | 00000000:01:00.0 N/A |                  N/A |
| N/A   53C    P8    N/A /  N/A |      1MiB /   454MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0                    Not Supported                                       |
+-----------------------------------------------------------------------------+

And the result of nvidia-settings :

ERROR: Unable to find display on any available system

The mouse seems to lag less when the laptop is on battery, but not sure. And it fixes my HDMI audio output problem which is already a nice thing :slight_smile: .

@AndreasL I have the exact same problem (thinkpad T530 with Nvidia NVS5400M which uses Legacy390 driver). And I also had the exact same configuration as you. Up until a few days ago, it was working fine, I assume you run unstable. However after updating my channel and rebuilding nixos, I have the same problem now, nvidia driver doesnā€™t detect any displays and the system runs with software acceleration, so I assume something broke recently. (Note that offload isnā€™t supported in 390, so only sync mode works).

Hello @ClockGen,

No Iā€™m running on stable channel with NixOs 23.11.
Here is my config for my nvidia :

  hardware.opengl = {
    enable = true;
    driSupport = true;
    driSupport32Bit = true;
  };
  # Load nvidia driver for Xorg and Wayland
  # It's important to just put "nvidia" and not "nvidiaLegacy390"
  services.xserver.videoDrivers = ["nvidia"];
  hardware.nvidia = {

    # Modesetting is required.
    modesetting.enable = true;

    # Nvidia power management. Experimental, and can cause sleep/suspend to fail.
    # Enable this if you have graphical corruption issues or application crashes after waking
    # up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead 
    # of just the bare essentials.
    powerManagement.enable = false;

    # Fine-grained power management. Turns off GPU when not in use.
    # Experimental and only works on modern Nvidia GPUs (Turing or newer).
    powerManagement.finegrained = false;

    # Use the NVidia open source kernel module (not to be confused with the
    # independent third-party "nouveau" open source driver).
    # Support is limited to the Turing and later architectures. Full list of 
    # supported GPUs is at: 
    # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus 
    # Only available from driver 515.43.04+
    # Currently alpha-quality/buggy, so false is currently the recommended setting.
    open = false;

    # Enable the Nvidia settings menu,
	# accessible via `nvidia-settings`.
    nvidiaSettings = true;

    # Optionally, you may need to select the appropriate driver version for your specific GPU.
    package = config.boot.kernelPackages.nvidiaPackages.legacy_390;
    
    # see : https://nixos.wiki/wiki/Nvidia#Laptop_Configuration:_Hybrid_Graphics_.28Nvidia_Optimus_PRIME.29
    prime = {
    	sync.enable = true;
    	intelBusId = "PCI:0:2:0";
    	nvidiaBusId = "PCI:1:0:0";
    };
  };

  # Needed for nvidia drivers
  nixpkgs.config.nvidia.acceptLicense = true;

  environment.systemPackages = with pkgs; [
     # See https://discourse.nixos.org/t/nvidia-settings-and-nvidia-offload-not-found/37187/14?u=andreasl
     linuxKernel.packages.linux_6_1.nvidia_x11_legacy390
  ];

My real problem is about HDMI sound output which doesnā€™t with nouveau, and works with nvidia legacy.
Otherwise, I wouldnā€™t mind using nouveau, I donā€™t need a great performancesā€¦

Hello Guys,

Iā€™m facing a very similar issue, I have old Hardware and trying to make it work:

  • I need to use nvidiaLegacy390 (GPU model: Nvidia NVS 300), I still use VGA (sorry guys lol)

why:
the OS works overall but the text is blurry on some places and Iā€™m getting headache by watching the Screen, before I go to last option (buy an new PC with better hardware) Iā€™m trying now to downgrade the kernel thanks to the hint from @shico

Iā€™m a newbie in NixOS (I love it btw.) and in Linux but already setup a bit flake, home-manager - I was asking myself if I should build the kernel with --flake option, I guess yes? ah and for nvidia-settings commands I get command not found

Would appreciate if someone finds an solution, I would save some money :slight_smile:

Thanks in Advance

@AndreasL
Sorry for the late reply, Iā€™ve just seen your post. Currently I have this configuration which works well on the latest stable version of NixOS.

(Will share only relevant parts, if you want the complete file, you can tell me)

flake.nix:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
  };

  outputs = {
    nixpkgs,
    ...
  } @ inputs: {
    nixosConfigurations = {
      "nixos" = nixpkgs.lib.nixosSystem rec {
        system = "x86_64-linux";

        specialArgs = rec {
          inherit (inputs) nixpkgs;

          pkgs = import nixpkgs {
            system = system;

            config.allowUnfree = true;
            config.nvidia.acceptLicense = true;

            overlays = [
              (final: prev: {
                bumblebee = prev.bumblebee.override {
                  nvidia_x11 = pkgs.linuxKernel.packages.linux_6_1.nvidia_x11_legacy390;
                  extraNvidiaDeviceOptions = "BusID \"PCI:1:0:0\"";
                };
              })

              (final: prev: let
                xmodules = pkgs.lib.concatStringsSep "," (
                  map (x: "${x.out or x}/lib/xorg/modules") [
                    pkgs.xorg.xorgserver
                    pkgs.xorg.xf86inputmouse
                  ]
                );
              in {
                bumblebee = prev.bumblebee.overrideAttrs (old: {
                  nativeBuildInputs =
                    old.nativeBuildInputs
                    ++ [
                      pkgs.xorg.xf86inputmouse
                    ];
                  CFLAGS = [
                    "-DX_MODULE_APPENDS=\\\"${xmodules}\\\""
                  ];
                });
              })
            ];
          };

        modules = [
          ./configuration.nix
          ./hardware-configuration.nix
        ];
      };
    };
  };
}

hardware-configuration.nix:

{
  config,
  lib,
  pkgs,
  modulesPath,
  ...
}: {
  boot.kernelPackages = pkgs.linuxPackages.extend (self: super: {
    nvidia_x11 = super.nvidia_x11_legacy390;
  });

  services.xserver.videoDrivers = [
    "modesetting"
    "nvidiaLegacy390"
  ];

  hardware.nvidia = {
    modesetting.enable = true;
    powerManagement.enable = false;
    powerManagement.finegrained = false;
    open = false;
    nvidiaSettings = true;
    package = config.boot.kernelPackages.nvidiaPackages.legacy_390;
    prime = {
      offload = {
        enable = true;
        enableOffloadCmd = true;
      };
      intelBusId = "PCI:0:2:0";
      nvidiaBusId = "PCI:1:0:0";
    };
  };
  hardware.bumblebee.enable = true;

  hardware.opengl = {
    enable = true;
    driSupport = true;
    driSupport32Bit = true;

    extraPackages = with pkgs; [
      intel-media-driver
      (vaapiIntel.override {enableHybridCodec = true;})
      vaapiVdpau
      libvdpau-va-gl
    ];
  };
}

configuration.nix:

{
  nixpkgs,
  pkgs,
  pkgs-unstable,
  ...
}: {

  environment.systemPackages = with pkgs; [
    linuxKernel.packages.linux_6_1.nvidia_x11_legacy390
  ];
}

Running nvidia-smi in this configuration doesnā€™t work of course.
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
You would have to use it like this optirun nvidia-smi:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.157                Driver Version: 390.157                   |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  NVS 5200M           Off  | 00000000:01:00.0 N/A |                  N/A |
| N/A   47C    P0    N/A /  N/A |      5MiB /   964MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0                    Not Supported                                       |
+-----------------------------------------------------------------------------+

Thanks for your reply,
I tried to replicate your configuration, but got problems compiling it.
First, I was not using flake, so I activated it.
Then, my hardware-configuration.nix is specified to be automatically generated, so I didnā€™t touch it, so I copied all your hardware stuff in configuration.nix.

I think it quite OK but got a very obscure error when calling sudo nixos-rebuild switch :

warning: creating lock file '/etc/nixos/flake.lock'
error: flake 'path:/etc/nixos' does not provide attribute 'packages.x86_64-linux.nixosConfigurations."nixos".config.system.build.nixos-rebuild', 'legacyPackages.x86_64-linux.nixosConfigurations."nixos".config.system.build.nixos-rebuild' or 'nixosConfigurations."nixos".config.system.build.nixos-rebuild'

Here is my flake.nix file (the system = system line was creating an error so I just copied the system value) :

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
  };

  outputs = { self, nixpkgs } @inputs : {
    # replace 'joes-desktop' with your hostname here.
    nixosConfigurations.joes-desktop = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      
      specialArgs = rec {
          inherit (inputs) nixpkgs;

          pkgs = import nixpkgs {
            system = "x86_64-linux";

            config.allowUnfree = true;
            config.nvidia.acceptLicense = true;

            overlays = [
              (final: prev: {
                bumblebee = prev.bumblebee.override {
                  nvidia_x11 = pkgs.linuxKernel.packages.linux_6_1.nvidia_x11_legacy390;
                  extraNvidiaDeviceOptions = "BusID \"PCI:1:0:0\"";
                };
              })

              (final: prev: let
                xmodules = pkgs.lib.concatStringsSep "," (
                  map (x: "${x.out or x}/lib/xorg/modules") [
                    pkgs.xorg.xorgserver
                    pkgs.xorg.xf86inputmouse
                  ]
                );
              in {
                bumblebee = prev.bumblebee.overrideAttrs (old: {
                  nativeBuildInputs =
                    old.nativeBuildInputs
                    ++ [
                      pkgs.xorg.xf86inputmouse
                    ];
                  CFLAGS = [
                    "-DX_MODULE_APPENDS=\\\"${xmodules}\\\""
                  ];
                });
              })
            ];
          };      
      
        modules = [ ./configuration.nix ];
      }
    };
  };
}

Sorry, Iā€™m very new to nix, this problem may be obviousā€¦

Iā€™m not sure why it does not work. Have you tried just getting it work with flakes first without the overlay for bumblebee?

[Update]:
Copying and pasting your code snippet in my editor showed an error, youā€™re missing a semi-column at line 93, after the closing brace of specialArgs.

Same error, so itā€™s not about your overlay.

Nice catch, but it wasnā€™t the problem. I will try to fond a solution for my flake problem and then test back your overlay, thanks !

1 Like