From 0c507df09065042189f9e5f4cfcf612006e9a2e2 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Fri, 20 Sep 2024 07:48:01 +0200 Subject: [PATCH 1/2] mistral-rs: fix cuda support Co-authored-by: Someone Serge --- pkgs/by-name/mi/mistral-rs/package.nix | 31 +++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/pkgs/by-name/mi/mistral-rs/package.nix b/pkgs/by-name/mi/mistral-rs/package.nix index cb65ef0c7110..9903ed90480a 100644 --- a/pkgs/by-name/mi/mistral-rs/package.nix +++ b/pkgs/by-name/mi/mistral-rs/package.nix @@ -7,6 +7,8 @@ # nativeBuildInputs pkg-config, python3, + autoPatchelfHook, + autoAddDriverRunpath, # buildInputs oniguruma, @@ -86,10 +88,19 @@ rustPlatform.buildRustPackage (finalAttrs: { useFetchCargoVendor = true; cargoHash = "sha256-YGGtS8gJJQKIgXxMWjO05ikSVdfVNs+cORbJ+Wf88y4="; - nativeBuildInputs = [ - pkg-config - python3 - ] ++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc ]; + nativeBuildInputs = + [ + pkg-config + python3 + ] + ++ lib.optionals cudaSupport [ + # WARNING: autoAddDriverRunpath must run AFTER autoPatchelfHook + # Otherwise, autoPatchelfHook removes driverLink from RUNPATH + autoPatchelfHook + autoAddDriverRunpath + + cudaPackages.cuda_nvcc + ]; buildInputs = [ @@ -97,6 +108,7 @@ rustPlatform.buildRustPackage (finalAttrs: { openssl ] ++ lib.optionals cudaSupport [ + cudaPackages.cuda_cccl cudaPackages.cuda_cudart cudaPackages.cuda_nvrtc cudaPackages.libcublas @@ -132,13 +144,16 @@ rustPlatform.buildRustPackage (finalAttrs: { // (lib.optionalAttrs cudaSupport { CUDA_COMPUTE_CAP = cudaCapability'; - # Apparently, cudart is enough: No need to provide the entire cudaPackages.cudatoolkit derivation. + # We already list CUDA dependencies in buildInputs + # We only set CUDA_TOOLKIT_ROOT_DIR to satisfy some redundant checks from upstream CUDA_TOOLKIT_ROOT_DIR = lib.getDev cudaPackages.cuda_cudart; }); - NVCC_PREPEND_FLAGS = lib.optionals cudaSupport [ - "-I${lib.getDev cudaPackages.cuda_cudart}/include" - "-I${lib.getDev cudaPackages.cuda_cccl}/include" + appendRunpaths = [ + (lib.makeLibraryPath [ + cudaPackages.libcublas + cudaPackages.libcurand + ]) ]; # swagger-ui will once more be copied in the target directory during the check phase From 25c1a6ee15a2f1ae2f4d47842a633272855ca911 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 13 Apr 2025 15:41:45 +0200 Subject: [PATCH 2/2] release-cuda: build mistral-rs on nix-community Hydra --- pkgs/top-level/release-cuda.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/top-level/release-cuda.nix b/pkgs/top-level/release-cuda.nix index 4ebabe05e1f3..2d2deb1b34a2 100644 --- a/pkgs/top-level/release-cuda.nix +++ b/pkgs/top-level/release-cuda.nix @@ -105,6 +105,7 @@ let lightgbm = linux; llama-cpp = linux; meshlab = linux; + mistral-rs = linux; monado = linux; # Failed in https://github.com/NixOS/nixpkgs/pull/233581 noisetorch = linux; obs-studio-plugins.obs-backgroundremoval = linux;