Skip to content

intel-npu-driver: init at 1.22.0 #382756

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pseudocc
Copy link

@pseudocc pseudocc commented Feb 17, 2025

Packaging the Intel NPU firmware (for Linux kernel module: intel_vpu).

[nix-shell:~/.cache/nixpkgs-review/pr-382756-4]$ tree results/intel-npu-driver-x86_64-linux/
results/intel-npu-driver-x86_64-linux/
├── bin
│   ├── npu-kmd-test
│   └── npu-umd-test
└── lib
    ├── libze_intel_vpu.so -> libze_intel_vpu.so.1
    ├── libze_intel_vpu.so.1 -> libze_intel_vpu.so.1.13.0
    └── libze_intel_vpu.so.1.13.0

3 directories, 5 files

[nix-shell:~/.cache/nixpkgs-review/pr-382756-4]$ tree results/intel-npu-firmware-x86_64-linux
results/intel-npu-firmware-x86_64-linux
└── lib
    └── firmware
        └── intel
            └── vpu
                ├── mtl_vpu_v0.0.bin -> vpu_37xx_v0.0.bin
                ├── vpu_37xx_v0.0.bin
                └── vpu_40xx_v0.0.bin

5 directories, 3 files

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: hardware Drivers, Firmware and Kernels 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` labels Feb 17, 2025
@NixOSInfra NixOSInfra added the 12.first-time contribution This PR is the author's first one; please be gentle! label Feb 17, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Feb 17, 2025
@pseudocc
Copy link
Author

I created a flake for it, and verified the firmware worked well.
intel/linux-npu-driver#67
pseudocc/nix-config@27ee1af

Comment on lines +201 to +226
($device eq "0x7d1d" || $device eq "0xad1d" ||
$device eq "0x643e" || $device eq "0xb03e");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PCI ID are copied from the intel_vpu linux driver module.

Copy link
Member

@osbm osbm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only have trivial change requests, package seems sufficiently up to standard otherwise.

@jwludzik
Copy link

The NPU firmware is strictly connected with NPU compiler and driver. This is a problem, because whenever you want to use newer driver, ex. upcoming v1.14.0 release, then you should use the same firmware from the release as well. If the firmware is not matched with compiler, then we do not guarantee that all works correctly. Best would be to have a common package - firmware, driver and compiler. That is why the NPU firmware never reached the linux-firmware repository

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I question this entire module. It just does to little to be added.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just trying to get rid of the firmware loading error at the first place, while according to @jwludzik, other packages are also required to get NPU really work, I think it's good to keep the module to install all related packages together.

@@ -196,6 +196,11 @@ sub pciCheck {
($device eq "0x4229" || $device eq "0x4230" ||
$device eq "0x4222" || $device eq "0x4227");

push @attrs, "hardware.cpu.intel.enableNpuFirmware = true;" if
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend

Suggested change
push @attrs, "hardware.cpu.intel.enableNpuFirmware = true;" if
push @attrs, "hardware.firmware = [ pkgs.intel-npu-firmware ];" if

@pseudocc
Copy link
Author

Thank you guys for reviewing this, I am changing this to WIP for packaging related driver and compiler as well.

@pseudocc pseudocc marked this pull request as draft February 20, 2025 02:48
@pseudocc pseudocc changed the title intel-npu-firmware: init at 1.13.0 intel-npu-driver: init at 1.13.0 Feb 20, 2025
@h7x4 h7x4 added the 8.has: module (new) This PR adds a module in `nixos/` label Feb 24, 2025
@pseudocc pseudocc force-pushed the intel-npu-firmware branch 7 times, most recently from 4d7bb9c to 2d2b4c4 Compare February 26, 2025 06:21
@pseudocc pseudocc marked this pull request as ready for review February 26, 2025 07:22
@pseudocc pseudocc force-pushed the intel-npu-firmware branch from 74fcd25 to c232a62 Compare March 5, 2025 09:59
@pseudocc pseudocc requested a review from SuperSandro2000 March 5, 2025 10:09
@pseudocc pseudocc force-pushed the intel-npu-firmware branch from c232a62 to 0ba746a Compare March 5, 2025 14:52
@nilp0inter
Copy link
Contributor

Hi @pseudocc,

I wanted to share an experiment I conducted to streamline the package compilation process as suggested by @SuperSandro2000. Here's what I did:

  1. I added "firmware" to the list of outputs in the package configuration.

  2. I modified the postPatch section to include the following:

    substituteInPlace firmware/CMakeLists.txt \                      
      --replace-fail "DESTINATION /lib/firmware/updates/intel/vpu/" \
      "DESTINATION $firmware/lib/firmware/intel/vpu/"
  3. I removed the installPhase, compiling the whole package in a single step.

I hope this approach might be helpful as we work towards refining the packaging process.

@pseudocc
Copy link
Author

Hi @nilp0inter , I think that there might be a use case that the user just want the firmware only. If so, my implementation will not take any time preparing cmake env and building the artifacts since the firmware binary is in the source tree.

@nilp0inter
Copy link
Contributor

Thanks for the clarification @pseudocc . I was missing the point completely.

Cheers!

@izelnakri
Copy link
Contributor

Latest version of npu-driver is now v1.17 @pseudocc , lets update it and I don't want to hold back the PR from being merged. In fact, this PR has been on hold for 3 months for no good reason. Would appreciate if it gets approved & merged right after the update @SuperSandro2000 @pseudocc

inherit (intel-npu-driver) version src;
pname = "intel-npu-firmware";

installPhase = ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we then set dontBuild to make that obvious?

I am not sure if that optimisation is worth it. Having two packages to update is some overhead and r-ryantm cannot deal with that properly, also when doing inherits.

Why not comine them again and move the firmware to the respecting output?

owner = "intel";
repo = "linux-npu-driver";
rev = "v${version}";
fetchSubmodules = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vendoring libraries we already have in nixpkgs is not nice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However it is still necessary, please see: intel/level-zero-npu-extensions#36 intel-npu-driver has level-zero-npu-extensions vendored as git submodule from github directly. Please approve this PR @SuperSandro2000

udev
openssl
boost
level-zero
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make sure we are using our level-zero, we should delete the vendored.

Copy link
Author

@pseudocc pseudocc Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it in the postPatch section

rm third_party/cmake/level-zero.cmake

@pseudocc pseudocc force-pushed the intel-npu-firmware branch from 0ba746a to 2893356 Compare July 3, 2025 08:16
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. and removed 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. labels Jul 3, 2025
@pseudocc
Copy link
Author

pseudocc commented Jul 3, 2025

Ran npu-umd-test and npu-kmd-test looked fine on my ThinkPad X13 Yoga Gen5 (CPU: Intel(R) Core(TM) Ultra 5 135U).

$ patchelf --print-rpath $(which npu-umd-test
/nix/store/g4h8yviv4r2rfnwzlmc746s5ls22zvgd-level-zero-1.22.4/lib:/nix/store/q4wq65gl3r8fy746v9bbwgx4gzn0r2kl-glibc-2.40-66/lib:/nix/store/l7d6vwajpfvgsd3j4cr25imd1mzb7d1d-gcc-14.3.0-lib/lib

@pseudocc pseudocc requested a review from SuperSandro2000 July 3, 2025 09:00
@pseudocc pseudocc changed the title intel-npu-driver: init at 1.13.0 intel-npu-driver: init at 1.17.0 Jul 3, 2025
@pseudocc
Copy link
Author

pseudocc commented Jul 7, 2025

@SuperSandro2000 Nudge, any suggested changes?

Only support the standalone build.

Closes: NixOS#348739
@pseudocc pseudocc force-pushed the intel-npu-firmware branch from 2893356 to 1943dbf Compare July 14, 2025 02:16
@pseudocc pseudocc changed the title intel-npu-driver: init at 1.17.0 intel-npu-driver: init at 1.19.0 Jul 14, 2025
@dmivankov
Copy link
Contributor

For the firmware part looks like it's now upstreamed to linux-firmware https://web.git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/commit/?id=9b870dde196d030a6c8872e8965dd28a0146c990

@izelnakri
Copy link
Contributor

izelnakri commented Aug 6, 2025

@SuperSandro2000 @osbm @nmouha seems like this PR is more than 6 months old already and requested changes are made. Could you approve your reviews and lets merge this?

I've been custom configuring this to my config to utilize my NPU for far too long. Thanks! @pseudocc

@NeuerUser
Copy link

I've been custom configuring this to my config to utilize my NPU for far too long. Thanks!

Could you tell me how you did the custom config? I've been waiting for this PR for about six months now and would really like to use the NPU.

Thanks 🙏

@pseudocc
Copy link
Author

I've been custom configuring this to my config to utilize my NPU for far too long. Thanks!

Could you tell me how you did the custom config? I've been waiting for this PR for about six months now and would really like to use the NPU.

Thanks 🙏

@NeuerUser You may refer to mine (if you are also using flake): pseudocc/nix-config@6434c09

@pseudocc pseudocc changed the title intel-npu-driver: init at 1.19.0 intel-npu-driver: init at 1.22.0 Aug 15, 2025
@NeuerUser
Copy link

NeuerUser commented Aug 15, 2025

@NeuerUser You may refer to mine (if you are also using flake): pseudocc/nix-config@6434c09

Thanks a lot. I do, however, get an SHA error:

`

     specified: sha256-GxmAmbf28hn/ragkTkFBYbM6Z+uFR6X4foMOyE8UVAc=
        got:    sha256-e1pkwFXfnf9NyjAUGrJJB5r1ytI1l6X0X5GF63O868U=

`
EDIT: fixed it, sorry.

@dmivankov
Copy link
Contributor

Just as a datapoint, on 25.05 I managed to run validation without applying the module

$ LD_LIBRARY_PATH="$(nix-build -A intel-npu-driver.out)/lib" "$(nix-build -A intel-npu-driver.validation)/bin/npu-umd-test"

...
[ RUN      ] Umd.ConfigurationCheck
/build/source/validation/umd-test/umd_test.cpp:201: Failure
Expected: (config.size()) > (0), actual: 0 vs 0
Missed configuration file.
Test scope is reduced.
Provide valid configurtion file, use:
npu-umd-test -c/--config [CONFIGURATION_PATH]

[  FAILED  ] Umd.ConfigurationCheck (0 ms)
...
[ DISABLED ] MemoryExecution.DISABLED_CopyingFromUnpinnedHostMemoryShouldBeAllowed
...

all other tests are either passing or skipped

And for kmd

$ LD_LIBRARY_PATH="$(nix-build -A intel-npu-driver.out)/lib" sudo "$(nix-build -A intel-npu-driver.validation)/bin/npu-kmd-test"

...
[ RUN      ] Device.ResetComputeEngine
/build/source/validation/kmd-test/test_device.cpp:118: Failure
Expected equality of these values:
  write_debugfs_file("reset_engine", 0)
    Which is: 19
  0

[  FAILED  ] Device.ResetComputeEngine (3 ms)
[ DISABLED ] Device.DISABLED_ResetInvalidEngine
...
[ DISABLED ] UapiMem.DISABLED_BoClosedDuringCreate
...

and all other passing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: hardware Drivers, Firmware and Kernels 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 8.has: module (new) This PR adds a module in `nixos/` 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. 12.first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.