Nvidia-settings and nvidia-offload not found

This is from my hardware-confiugration.nix:

services.xserver.videoDrivers = [ "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";
  };
};

After running sudo nixos-rebuild switch and restarting my machine, running nvidia-settings or nvidia-offload doesn’t work.

to get nvidia-offload off the ground, I use a custom script. Which might be the old way of doing it. Like so:

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

let
  nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" ''
    export __NV_PRIME_RENDER_OFFLOAD=1
    export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
    export __GLX_VENDOR_LIBRARY_NAME=nvidia
    export __VK_LAYER_NV_optimus=NVIDIA_only
    exec "$@"
  '';
in

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

    intelBusId = "PCI:0:2:0";
    nvidiaBusId = "PCI:1:0:0";
  };

  environment.systemPackages = [ nvidia-offload ];
}

Now it appears that enableOffloadCmd should be doing more or less the same thing I guess. Not really sure why I does not.

1 Like

I tried to copy this in a local file and use it to run glxinfo -B but it never switches to my nvidia GPU, always using the Intel one. Do you have nvidia-settings installed btw?

wdym copy this to a local file and use it to run glxinfo? You mean just the script?

Anyways, if I run it, I get this:

nvidia-offload glxinfo -B

name of display: :0
display: :0  screen: 0
direct rendering: Yes
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 2048 MB
    Total available memory: 2048 MB
    Currently available dedicated video memory: 1998 MB
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: NVIDIA GeForce MX150/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 545.29.02
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.6.0 NVIDIA 545.29.02
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)

OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 545.29.02
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

And yes, I do have nvidia-settings. My Nvidia GPU shows up as GPU0 in there. Plus some additional info obviously (like the bus id mentioned in the config).

If I save this

    export __NV_PRIME_RENDER_OFFLOAD=1
    export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
    export __GLX_VENDOR_LIBRARY_NAME=nvidia
    export __VK_LAYER_NV_optimus=NVIDIA_only
    exec "$@"

to a file called nvidia-offload and chmod +x it, then do ./nvidia-offload glxinfo -B
I get this:

name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Intel (0x8086)
    Device: Mesa Intel(R) HD Graphics 4000 (IVB GT2) (0x166)
    Version: 23.1.9
    Accelerated: yes
    Video memory: 1536MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.2
    Max compat profile version: 4.2
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.0
OpenGL vendor string: Intel
OpenGL renderer string: Mesa Intel(R) HD Graphics 4000 (IVB GT2)
OpenGL core profile version string: 4.2 (Core Profile) Mesa 23.1.9
OpenGL core profile shading language version string: 4.20
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.2 (Compatibility Profile) Mesa 23.1.9
OpenGL shading language version string: 4.20
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.0 Mesa 23.1.9
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00

Running nvidia-settings also doesn’t work. It says that command not found

It seems like the driver isn’t installed at all.
Running cd /nix/store && ls | grep --ignore-case nvidia returns nothing.

That would appear to make a lot of sense then! :sweat_smile:

For me that returns a whole lot of things.

Also you should check lsmod | grep nvidia to see if the kernel module is actually loaded. Which of course it won’t be now, that it’s not even in the nix store.

I think I’ve found out why it is not installed.

Does this mean that this driver is only supported for kernels older than 6.2 or 6.2 and higher?

That would make sense. Maybe get the LTS kernel instead?

My kernel was 6.1. Will try boot.kernelPackages = pkgs.linuxPackages_zen;. It’s supposed to give me kernel 6.6.1. I am still not sure what kernel.kernelAtLeast means though. I assume the kernel has to be minimum v6.2 for the package to work?

I’d read that it has to be at least 6.2 for the package to be broken. Without checking what the function actually does, I’d say it evaluates to true on kernel 6.2 and above. Hence the package should be broken on kernel 6.2 and above.

Why are you using the zen kernel? That one is modified. No idea what that will do in your case.

Oh, so I’m supposed to run a kernel that is 6.1 or older?

Well, I am not sure about the exact nature of your config. But what I can gather from this is that this package legacy_390 is likely to not work on kernel 6.2 and above.

I myself am running 6.1.63 on this machine right now btw. (Edit: I just use linuxPackages as kernel packages for NixOS, which should give you the LTS. According to kernel.org this is at 6.1.69 right now.)

Generally speaking I am also not totally familiar with what your system configuration as a whole is. It appears to be somewhat older, based on Intel Ivy Bridge or Haswell or so. Also your Nvidia driver is not very up to date, is that because your GPU is not supported by newer versions?

You’re right! I went back to the default LTS kernel, 6.1.65. However, it still didn’t install. I had to manually add linuxKernel.packages.linux_6_1.nvidia_x11_legacy390 to environment.systemPackages. And indeed it did install without issues. I guess the hardware.nvidia config doesn’t support old drivers or something, not sure.

Yes, my hardware is old, the GPU is so old that it doesn’t even support vulkan lol.

I think I’m getting closer. I just need to figure out how to load the nvidia kernel module because bumblebee shows this error nixos bumblebeed[910]: Could not load GPU driver. I wonder if I should add "nvidia" to the boot.initrd.kernelModules list. I already added it to the boot.kernelModules one.

I just need to figure out how to load the nvidia kernel module

That would most likely be a big step forward.

At this point I have to ask: Is your GPU even supported by the legacy 390 drivers? Which GPU are you running?

Yes, it is. I checked the Nvidia website, and used to run it when I was running Arch. It is working now, but bumblebee for some reason installs a different version of the Nvidia driver. Thanks for your help!

1 Like

I need to override this dependency somehow and make it nvidia_x11_legacy390

Is this the correct way to do it?

nixpkgs.overlays = [
  (final: prev: {
      bumblebee = prev.bumblebee.override { nvidia_x11 = prev.nvidia_x11_legacy390; };
  })
];

Hi @shico,

I got the same problem for my old 4200M card.
Did you fix your issue ? I so, can you post you configuration.nix file (at least the part concerned by your kernel, opengl and nvidia) ?

Thanks,
Andréas

Hi,

I think I went a bit further, thanks to this topic : Nvidia 390 driver not working - #3 by the_pumpkin_man

videoDriver must be nvidia in order to be able to load the kernel module.

services.xserver.videoDrivers = [ "nvidia" ];

After that, the kernel module is loaded, got nvidia-settings in my path, but it doesn’t find any display.

In the end, I still don’t know if my GPU is in use or if the integrated intel GPU is used.

Also, my laptop performances seems ok but the mouse is lagggging a lot which make it unusable.

Hope we’ll find a solution to this problem.

And, does anyone know how to check if your nvidia GPU is compatible with optimus ? Nvidia has a website : Optimus | Supported GPUs | GeForce but it seems completely broken…

If my card is not supported by optimus, how can the intel card and nvidia one work together ?