diff --git a/src/default.nix b/src/default.nix index e73fec7..db5146b 100644 --- a/src/default.nix +++ b/src/default.nix @@ -31,6 +31,7 @@ oneTBB = callPackage ./onetbb.nix { #inherit llvm; }; + openvino = callPackage ./openvino.nix {}; spirv-llvm-translator = callPackage ./spirv-llvm-translator.nix {}; spirv-llvm-translator-test = @@ -72,6 +73,7 @@ oneDNN oneMath oneTBB + openvino ; }; llama-cpp = callPackage ./ggml/llama-cpp.nix { diff --git a/src/ggml/whisper-cpp.nix b/src/ggml/whisper-cpp.nix index a509ffd..abf9032 100644 --- a/src/ggml/whisper-cpp.nix +++ b/src/ggml/whisper-cpp.nix @@ -1,52 +1,137 @@ -{ - fetchFromGitHub, - llvm, - cmake, - ninja, - oneDNN, - oneMath, - oneTBB, - # mkl, - git, - opencl-headers, - ocl-icd, -}: let - version = "1.7.6"; -in - llvm.stdenv.mkDerivation { - pname = "whisper-cpp"; - inherit version; - - src = fetchFromGitHub { - owner = "ggml-org"; - repo = "whisper.cpp"; - tag = "v${version}"; - hash = "sha256-dppBhiCS4C3ELw/Ckx5W0KOMUvOHUiisdZvkS7gkxj4="; - }; - - nativeBuildInputs = [ - cmake - ninja - git - ]; +{ autoAddDriverRunpath +, cmake +, fetchFromGitHub +, git +, lib +, llvm +, llvmPackages +, makeWrapper +, oneDNN +, oneMath +, oneTBB +, openvino +, SDL2 +, opencl-headers +, ocl-icd +, openblas # NOTE: needed for now until whisper.cpp moves to OneMath +, runCommand +}: +let + oneMathCmakeShim = runCommand "oneMathCmakeShim" { buildInputs = [ - oneDNN oneMath - oneTBB - # mkl opencl-headers ocl-icd llvm.baseLlvm.openmp ]; + } '' + mkdir -p $out/lib/cmake/OpenCL + mkdir -p $out/lib/cmake/MKL - hardeningDisable = [ - "zerocallusedregs" - "pacret" - # "shadowstack" - ]; + cat > $out/lib/cmake/MKL/MKLConfig.cmake < $out/lib/cmake/OpenCL/OpenCLConfig.cmake < ie_dependency.info + popd + ''; + + dontUseSconsCheck = true; + dontUseSconsBuild = true; + dontUseSconsInstall = true; + + cmakeFlags = [ + "-Wno-dev" + "-DCMAKE_MODULE_PATH:PATH=${placeholder "out"}/lib/cmake" + "-DCMAKE_PREFIX_PATH:PATH=${placeholder "out"}" + + "-DCMAKE_CXX_FLAGS=-Wno-odr" + "-DCMAKE_C_FLAGS=-Wno-odr" + + "-DOpenCV_DIR=${lib.getLib opencv}/lib/cmake/opencv4/" + "-DProtobuf_LIBRARIES=${protobuf}/lib/libprotobuf${stdenv.hostPlatform.extensions.sharedLibrary}" + "-DPython_EXECUTABLE=${python.interpreter}" + + (cmakeBool "CMAKE_VERBOSE_MAKEFILE" true) + (cmakeBool "NCC_STYLE" false) + (cmakeBool "ENABLE_CPPLINT" false) + (cmakeBool "ENABLE_SAMPLES" false) + + # features + (cmakeBool "ENABLE_INTEL_CPU" stdenv.hostPlatform.isx86_64) + (cmakeBool "ENABLE_INTEL_GPU" true) + (cmakeBool "ENABLE_INTEL_NPU" stdenv.hostPlatform.isx86_64) + (cmakeBool "ENABLE_JS" false) # NOTE: What is this?! + (cmakeBool "ENABLE_LTO" true) + (cmakeBool "ENABLE_OPENCV" true) + # This fails regardless: + (cmakeBool "ENABLE_OV_JAX_FRONTEND" false) # on true: auto-patchelf could not satisfy dependency libopenvino_jax_frontend.so.2450 + (cmakeBool "ENABLE_PYTHON" true) + + # system libs + (cmakeBool "ENABLE_SYSTEM_FLATBUFFERS" true) + (cmakeBool "ENABLE_SYSTEM_OPENCL" true) + (cmakeBool "ENABLE_SYSTEM_PROTOBUF" false) # NOTE: Change this? + (cmakeBool "ENABLE_SYSTEM_PUGIXML" true) + (cmakeBool "ENABLE_SYSTEM_SNAPPY" true) + (cmakeBool "ENABLE_SYSTEM_TBB" true) + ]; + + autoPatchelfIgnoreMissingDeps = [ + "libngraph_backend.so" + ]; + + buildInputs = [ + flatbuffers + gflags + level-zero + libusb1 + libxml2 + ocl-icd + opencv + pugixml + snappy + tbb_2022 + tree + ] + ++ lib.optionals cudaSupport [ + cudaPackages.cuda_cudart + ]; + + enableParallelBuilding = true; + + postInstall = '' + mkdir -p $out/lib $out/include $out/lib/cmake/openvino + + for lib in $out/runtime/lib/intel64/*; do + ln -s "$lib" $out/lib/ || cp -a "$lib" $out/lib/ + done + + for hdr in $out/runtime/include/*; do + ln -s "$hdr" $out/include/ || cp -a "$hdr" $out/include/ + done + + for cmakeFile in $out/runtime/cmake/*; do + ln -s "$cmakeFile" $out/lib/cmake/openvino/ || cp -a "$cmakeFile" $out/lib/cmake/openvino/ + done + + mkdir -p $python + mv $out/python/* $python/ + rmdir $out/python + ''; + + postFixup = '' + # Link to OpenCL + find $out -type f \( -name '*.so' -or -name '*.so.*' \) | while read lib; do + addDriverRunpath "$lib" + done + ''; + + meta = with lib; { + changelog = "https://github.com/openvinotoolkit/openvino/releases/tag/${src.tag}"; + description = "OpenVINO™ Toolkit repository"; + longDescription = '' + This toolkit allows developers to deploy pre-trained deep learning models through a high-level C++ Inference Engine API integrated with application logic. + + This open source version includes several components: namely Model Optimizer, nGraph and Inference Engine, as well as CPU, GPU, MYRIAD, + multi device and heterogeneous plugins to accelerate deep learning inferencing on Intel® CPUs and Intel® Processor Graphics. + It supports pre-trained models from the Open Model Zoo, along with 100+ open source and public models in popular formats such as Caffe*, TensorFlow*, MXNet* and ONNX*. + ''; + homepage = "https://docs.openvinotoolkit.org/"; + license = with licenses; [ asl20 ]; + platforms = platforms.all; + broken = stdenv.hostPlatform.isDarwin; # Cannot find macos sdk + maintainers = with maintainers; [ tfmoraes ]; + }; +} diff --git a/src/unified-runtime.nix b/src/unified-runtime.nix index 53a56aa..cbef641 100644 --- a/src/unified-runtime.nix +++ b/src/unified-runtime.nix @@ -160,7 +160,7 @@ (lib.cmakeBool "UR_BUILD_TESTS" buildTests) (lib.cmakeBool "UR_BUILD_ADAPTER_L0" levelZeroSupport) - (lib.cmakeBool "UR_BUILD_ADAPTER_L0_V2" false) + (lib.cmakeBool "UR_BUILD_ADAPTER_L0_V2" levelZeroSupport) (lib.cmakeBool "UR_BUILD_ADAPTER_OPENCL" openclSupport) (lib.cmakeBool "UR_BUILD_ADAPTER_CUDA" cudaSupport) (lib.cmakeBool "UR_BUILD_ADAPTER_HIP" rocmSupport)