From 15b29960b865fe77724efc40ca8175d8a510a7ca Mon Sep 17 00:00:00 2001 From: winston Date: Wed, 3 Jun 2026 19:24:16 +0200 Subject: [PATCH] onnxruntime: add openvino support Co-authored-by: Martin Weinelt --- pkgs/by-name/on/onnxruntime/package.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkgs/by-name/on/onnxruntime/package.nix b/pkgs/by-name/on/onnxruntime/package.nix index 4253d258d8b2..9f0668874d96 100644 --- a/pkgs/by-name/on/onnxruntime/package.nix +++ b/pkgs/by-name/on/onnxruntime/package.nix @@ -25,10 +25,12 @@ pythonSupport ? (stdenv.buildPlatform.canExecute stdenv.hostPlatform), cudaSupport ? config.cudaSupport, ncclSupport ? cudaSupport && cudaPackages.nccl.meta.available, + openvinoSupport ? stdenv.isLinux, rocmSupport ? config.rocmSupport, coremlSupport ? stdenv.hostPlatform.isDarwin, withFullProtobuf ? false, cudaPackages ? { }, + openvino, rocmPackages, }@inputs: @@ -234,6 +236,9 @@ effectiveStdenv.mkDerivation (finalAttrs: { rocmPackages.rocm-smi rocmPackages.roctracer ] + ++ lib.optionals openvinoSupport [ + openvino + ] ++ lib.optionals effectiveStdenv.hostPlatform.isDarwin [ (darwinMinVersionHook "13.3") ]; @@ -292,6 +297,20 @@ effectiveStdenv.mkDerivation (finalAttrs: { (lib.cmakeBool "onnxruntime_USE_COREML" coremlSupport) (lib.cmakeBool "onnxruntime_ENABLE_LTO" (!cudaSupport || cudaPackages.cudaOlder "12.8")) ] + ++ lib.optionals openvinoSupport [ + (lib.cmakeBool "onnxruntime_USE_OPENVINO" true) + (lib.cmakeFeature "onnxruntime_USE_OPENVINO_AUTO" ( + if effectiveStdenv.hostPlatform.system == "x86_64-linux" then "NPU,GPU,CPU" else "GPU" + )) + (lib.cmakeBool "onnxruntime_USE_OPENVINO_GPU" true) + (lib.cmakeBool "onnxruntime_USE_OPENVINO_CPU" ( + effectiveStdenv.hostPlatform.system == "x86_64-linux" + )) + (lib.cmakeBool "onnxruntime_USE_OPENVINO_NPU" ( + effectiveStdenv.hostPlatform.system == "x86_64-linux" + )) + (lib.cmakeFeature "OpenVINO_DIR" "${lib.getDev openvino}/runtime/cmake") + ] ++ lib.optionals pythonSupport [ (lib.cmakeBool "onnxruntime_ENABLE_PYTHON" true) ]