Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvidia fails to build on unstable #90459

Closed
teto opened this issue Jun 15, 2020 · 15 comments
Closed

nvidia fails to build on unstable #90459

teto opened this issue Jun 15, 2020 · 15 comments
Labels
0.kind: bug Something is broken 6.topic: kernel The Linux kernel

Comments

@teto
Copy link
Member

teto commented Jun 15, 2020

Describe the bug
Nvidia fails to build with 5.7 on unstable.

/build/kernel/nvidia/nv-vm.c: In function 'nv_set_memory_array_type':
/build/kernel/nvidia/nv-vm.c:66:13: error: implicit declaration of function 'set_memory_array_uc'; did you mean 'set_pages_array_uc'? [-Werror=implicit-function-declaration]
   66 |             set_memory_array_uc(pages, num_pages);
      |             ^~~~~~~~~~~~~~~~~~~
      |             set_pages_array_uc
/build/kernel/nvidia/nv-vm.c:69:13: error: implicit declaration of function 'set_memory_array_wb'; did you mean 'set_pages_array_wb'? [-Werror=implicit-function-declaration]
   69 |             set_memory_array_wb(pages, num_pages);
      |             ^~~~~~~~~~~~~~~~~~~
      |             set_pages_array_wb

builder for '/nix/store/qlkblmpmz43vgl8ydh3zj7if0mzrp1jl-nvidia-x11-440.82-5.7.2.drv' failed with exit code 2

Seems like there is a fix

@teto teto added the 0.kind: bug Something is broken label Jun 15, 2020
@gkleen
Copy link
Contributor

gkleen commented Jun 15, 2020

I just did some research on this and found the following (including a patch):

https://forums.developer.nvidia.com/t/nvidia-440-82-kernel-5-7-patch/125815/5

@teto
Copy link
Member Author

teto commented Jun 15, 2020

oops I found that link and forgot to add it in my message after Seems like there is a fix xD

@veprbl
Copy link
Member

veprbl commented Jun 15, 2020

cc @eadwu @baracoder

@vcunat vcunat added the 6.topic: kernel The Linux kernel label Jun 17, 2020
@Patryk27
Copy link
Member

Patryk27 commented Jun 17, 2020

As a quick fix from user-side (configuration.nix), you can do:

{ ... }: {
  # ...

  nixpkgs = {
    overlays = [
      (self: super: {
        linuxPackages_latest = super.linuxPackages_latest.extend (self: super: {
          nvidia_x11 = super.nvidia_x11.overrideAttrs (attrs: {
            patches = [
              ./nvidia/conftest.patch
            ];
          });
        });
      })
    ];
  };
}

edit: there's a better snippet a few posts below

@srid
Copy link
Contributor

srid commented Jun 19, 2020

@Patryk27 That did not work for me (the patch doesn't seem to be applied). Is your config online?

@Patryk27
Copy link
Member

@srid: Unfortunately, I don't have my configuration online - an excerpt that's responsible for configuring nvidia on my machine is: https://gist.github.com/Patryk27/696ed8c3d7ff028c5ca84a3ee06ba745. Could you maybe post your logs for nixos-rebuild switch? I'd be more than happy to help in figuring out the issue.

@romildo
Copy link
Contributor

romildo commented Jun 20, 2020

I have the following in configuration.nix, the patch is applied, but compilation still fails.

    nixpkgs.overlays = [
      (self: super: {
        linuxPackages_latest = super.linuxPackages_latest.extend (self: super: {
          nvidia_x11 = super.nvidia_x11.overrideAttrs (attrs: {
            patches = [
              (pkgs.fetchpatch {
                name = "nvidia-kernel-5.7.patch";
                url = "https://gitlab.com/snippets/1965550/raw";
                sha256 = "03iwxhkajk65phc0h5j7v4gr4fjj6mhxdn04pa57am5qax8i2g9w";
              })
            ];
          });
        });
      })
    ];
[...]
patching sources
applying patch /nix/store/8lndb4192rlp7a7c0skgbrd9sjyx3wfw-nvidia-kernel-5.7.patch
patching file kernel/conftest.sh
configuring
[...]
/build/kernel/nvidia/nv-vm.c: In function 'nv_set_memory_array_type':
/build/kernel/nvidia/nv-vm.c:66:13: error: implicit declaration of function 'set_memory_array_uc'; did you mean 'set_pages_array_uc'? [-Werror=implicit-function-declaration]
   66 |             set_memory_array_uc(pages, num_pages);
      |             ^~~~~~~~~~~~~~~~~~~
      |             set_pages_array_uc
/build/kernel/nvidia/nv-vm.c:69:13: error: implicit declaration of function 'set_memory_array_wb'; did you mean 'set_pages_array_wb'? [-Werror=implicit-function-declaration]
   69 |             set_memory_array_wb(pages, num_pages);
      |             ^~~~~~~~~~~~~~~~~~~
      |             set_pages_array_wb
[...]

@Patryk27
Copy link
Member

@romildo: How are you using your Nvidia drivers - just something like services.xserver.videoDrivers = [ "modesetting" "nvidia" ];?

I've had that issue before too (patch being seemingly ignored), and - in my case - it was caused by Nvidia being loaded twice, in different versions (I was doing OPENCL_VENDOR_PATH = "${pkgs.linuxPackages.nvidia_x11}/etc/OpenCL/vendors"; somewhere inside my configuration.nix instead of referring to pkgs.linuxPackages_latest).

@romildo
Copy link
Contributor

romildo commented Jun 20, 2020

Here are the sections of the configuration.nix where nvidia is mentioned on my system.

{ config, pkgs, ... }:

let

  myNvidia = {
    # NVIDIA Optimus Prime: prime render offload
    # Https://nixos.wiki/wiki/Nvidia
    # https://github.com/NixOS/nixpkgs/pull/66601
    hardware.nvidia.prime.sync.enable = true;
    #hardware.nvidia.prime.offload.enable = true;
    hardware.nvidia.prime.intelBusId = "PCI:0:2:0";
    hardware.nvidia.prime.nvidiaBusId = "PCI:1:0:0";
    #hardware.nvidia.modesetting.enable = true; ###! ??? prevent tearing

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

    services.xserver.displayManager.sddm.setupScript = ''
      # workaround for using NVIDIA Optimus without Bumblebee
      xrandr --setprovideroutputsource modesetting NVIDIA-0
      xrandr --auto
    '';

    nixpkgs.overlays = [
      (self: super: {
        linuxPackages_latest = super.linuxPackages_latest.extend (self: super: {
          nvidia_x11 = super.nvidia_x11.overrideAttrs (attrs: {
            patches = [
              (pkgs.fetchpatch {
                name = "nvidia-kernel-5.7.patch";
                url = "https://gitlab.com/snippets/1965550/raw";
                sha256 = "03iwxhkajk65phc0h5j7v4gr4fjj6mhxdn04pa57am5qax8i2g9w";
              })
            ];
          });
        });
      })
    ];
  };

  # ...

in

{
  imports = [
    myNvidia
    # ...
  ];
  
  # ...
}

@Patryk27
Copy link
Member

Patryk27 commented Jun 20, 2020

Thanks; @srid, @romildo - the issue was that nvidia-settings and nvidia-persistenced were still being compiled with the unpatched version (I haven't had this case, because those apps are disabled for bumblebee).

Could you please try this one?

{ config, pkgs, ... }: {
  nixpkgs.overlays = [
    (self: super: {
      linuxPackages_latest = super.linuxPackages_latest.extend (self: super: {
        nvidiaPackages = super.nvidiaPackages // {
          stable = super.nvidiaPackages.stable.overrideAttrs (attrs: {
            patches = [
              (pkgs.fetchpatch {
                name = "nvidia-kernel-5.7.patch";
                url = "https://gitlab.com/snippets/1965550/raw";
                sha256 = "03iwxhkajk65phc0h5j7v4gr4fjj6mhxdn04pa57am5qax8i2g9w";
              })
            ];

            passthru = {
              settings = pkgs.callPackage (import <nixpkgs/pkgs/os-specific/linux/nvidia-x11/settings.nix> self.nvidiaPackages.stable "15psxvd65wi6hmxmd2vvsp2v0m07axw613hb355nh15r1dpkr3ma") {
                withGtk2 = true;
                withGtk3 = false;
              };

              persistenced = pkgs.lib.mapNullable (hash: pkgs.callPackage (import <nixpkgs/pkgs/os-specific/linux/nvidia-x11/persistenced.nix> self.nvidiaPackages.stable hash) { }) "13izz9p2kg9g38gf57g3s2sw7wshp1i9m5pzljh9v82c4c22x1fw";
            };
          });
        };
      });
    })
  ];
}

(for reference: those two fancy hashes were copied from pkgs/os-specific/linux/nvidia-x11/default.nix)

@srid
Copy link
Contributor

srid commented Jun 21, 2020

@Patryk27 That worked, thanks!

@baracoder baracoder mentioned this issue Jun 25, 2020
10 tasks
@kuznero
Copy link
Member

kuznero commented Jun 28, 2020

This workaround fixed it for me too.

@ghedamat
Copy link

confirming the workaround as well. the backport for 20.03 looks merged but updating nix-channel was not enough for me, I might have missed something...

@jahkeup
Copy link
Contributor

jahkeup commented Jun 29, 2020

the backport for 20.03 looks merged but updating nix-channel was not enough for me, I might have missed something...

The latest commit for nixos-20.03 looks like its older than the backport's, I suspect we're waiting on builds and a merge to the release branch. You can see the merged commits on the branch here:

https://github.com/NixOS/nixpkgs-channels/commits/nixos-20.03

@Atemu
Copy link
Member

Atemu commented Jul 9, 2020

The nvidia update PR which fixed the issue is in both unstable and stable now.

@Atemu Atemu closed this as completed Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: kernel The Linux kernel
Projects
None yet
Development

No branches or pull requests