NVIDIA drivers don’t work

I have a Lenovo Legion Y530 with an Intel integrated graphics processor along with an Nvidia 1050Ti. I’m trying to configure the system to work with my graphics card, in particular, Blender. I’ve already discovered the cudaSupport flag and enabled it, and, curiously, this actually succeeded until I rebooted. Now, the GPU is once again not working. I’m following the instructions at Nvidia - NixOS Wiki, and running nvidia-offload on Blender & Firefox gives errors:

anselmschueler@buggeryyacht-nixos ~> nvidia-offload firefox
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: Failed GL context creation for WebRender: (nil) (t=0.457541) [GFX1-]: Failed GL context creation for WebRender: (nil)
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: Failed GL context creation for WebRender: (nil) (t=0.457541) |[1][GFX1-]: FEATURE_FAILURE_WEBRENDER_INITIALIZE_UNSPECIFIED (t=0.457565) [GFX1-]: FEATURE_FAILURE_WEBRENDER_INITIALIZE_UNSPECIFIED
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: Failed GL context creation for WebRender: (nil) (t=0.457541) |[1][GFX1-]: FEATURE_FAILURE_WEBRENDER_INITIALIZE_UNSPECIFIED (t=0.457565) |[2][GFX1-]: Failed to connect WebRenderBridgeChild. (t=0.457702) [GFX1-]: Failed to connect WebRenderBridgeChild.
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: Failed GL context creation for WebRender: (nil) (t=0.457541) |[1][GFX1-]: FEATURE_FAILURE_WEBRENDER_INITIALIZE_UNSPECIFIED (t=0.457565) |[2][GFX1-]: Failed to connect WebRenderBridgeChild. (t=0.457702) |[3][GFX1-]: Fallback WR to SW-WR (t=0.457843) [GFX1-]: Fallback WR to SW-WR

###!!! [Parent][RunMessage] Error: Channel closing: too late to send/recv, messages will be lost

anselmschueler@buggeryyacht-nixos ~> nvidia-offload blender
Read prefs: /home/anselmschueler/.config/blender/2.93/config/userpref.blend
Error! Unsupported graphics card or driver.
A graphics card and driver with support for OpenGL 3.3 or higher is required.
The program will now close.
anselmschueler@buggeryyacht-nixos ~ [1]>

I’m at a complete loss as to what could be causing this. I’ve searched far & wide, and I’ve tried many things, such as modesetting, Optimus-less mode (my card seems to be output-producing), etc…

I’m on the unstable channel (though it also does not work on the NixOS 21.05 channel).
My /etc/nixos/configuration.nix (with the comments removed & the hashed password redacted) is as follows:

{ config, pkgs, ... }:
{
  imports =
    [ 
      ./hardware-configuration.nix
    ];
  boot.loader.systemd-boot.enable = true;
  boot.loader.systemd-boot.editor = false;
  boot.loader.efi.canTouchEfiVariables = true;
  networking.hostName = "buggeryyacht-nixos"; 
  time.timeZone = "Europe/Berlin";
  networking.useDHCP = false;
  networking.interfaces.enp8s0.useDHCP = true;
  networking.interfaces.wlp7s0.useDHCP = true;
  i18n.defaultLocale = "en_GB.UTF-8";
  console = {
    font = "Lat2-Terminus16";
    keyMap = "de";
  };
  services.xserver.enable = true;
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;
  services.xserver.desktopManager.xterm.enable = false;
  services.xserver.videoDrivers = [ "nvidia" ];
  hardware.opengl.driSupport32Bit = true;
  hardware.opengl.driSupport = true;
  hardware.nvidia.prime = {
    offload.enable = true;
    intelBusId = "PCI:0:2:0";
    nvidiaBusId = "PCI:1:0:0";
  };
  services.gnome.core-developer-tools.enable = true;
  services.gnome.games.enable = true;
  environment.gnome.excludePackages = with pkgs; [
    gnome.gnome-calculator
    gnome.gnome-terminal
    gnome.epiphany
  ];
  services.xserver.layout = "de";
  services.xserver.xkbOptions = "eurosign:e";
  services.xserver.xkbVariant = "nodeadkeys";
  services.printing.enable = true;
  sound.enable = true;
  hardware.pulseaudio.enable = true;
  services.xserver.libinput.enable = true;
  nixpkgs.config.allowUnfree = true;
  users.mutableUsers = false;
  users.users.anselmschueler = {
    isNormalUser = true;
    description = "Anselm Schüler";
    extraGroups = [ "wheel" ]; 
    hashedPassword = "$6$........$xo1trDFZ6O13y2R5j61aZZdpiw6RXMONw1eoWxVllWK7ziZ1U2dk3eWGr4/20PB3OgxAs0kWvPXHCm4NCC7Mr0";
    shell = pkgs.fish;
    packages = with pkgs; [
      steam
      inkscape
      lutris
      minecraft
      discord
      element-desktop
      tdesktop
      qbittorrent
      musescore
      audacity
      vscode
      (pkgs.blender.override { cudaSupport = true; })
      cudatoolkit
    ];
  };
  environment.shells = [ pkgs.fish ];
  environment.systemPackages = with pkgs; [
    nano 
    wget
    curl
    firefox
    kitty
    mpv
    vlc
    git
    fish
    gnome.gnome-sound-recorder
    gnome.gnome-tweaks
    qalculate-gtk
    pciutils
    lsof
    libreoffice
    cudatoolkit
    killall
    xorg.xwininfo
    xorg.xkill
    (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 -a "$0" "$@"
    '')
  ];
  fonts.fonts = with pkgs; [
    cascadia-code
    noto-fonts
    noto-fonts-cjk
    noto-fonts-emoji
    fira-code
    fira-code-symbols
  ];
  system.stateVersion = "21.05"; 
}

Additional info—I’m sure the PCI port numbers are correct. Here’s my lspci | grep -i vga output:

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] (rev a1)

if it suceeded before reboot, then the config should be correct, though I suspect you are not showing everything as almost nothing shown in the above config has anything to do with render offload. If it stopped working after a reboot then you probably did not make it the boot default. This can happen a couple of ways, for example, when using nixos-rebuild test instead of switch.

Also, I tried to respond to you on the matrix, perhaps you missed it though:
https://matrix.to/#/!KqkRjyTEzAGRiZFBYT:nixos.org/$5zXCao55HVcwlLpZuVoKwGMCHjXHTtFqOUcDXIp_OK0?via=nixos.org&via=matrix.org&via=tchncs.de

Thanks for the answer, but I believe this is not the culprit. I did rebuild with rebuild switch and rebooted to check. However, I have managed to alleviate the issue by adding hardware.nvidia.nvidiaPersistenced = true;.

To be sure, I will retest again when I get back home to my machine.

I didn’t need persistence, but it could be the descrepency in our hardware. I was provisioning a turing chip. Glad you got it working :+1:

1 Like

I got back to my PC to discover that the long suspend time stopped the GPU once again, rebooting fixed it, and it hasn’t recurred yet.