Skip to content

Commit 60ecf09

Browse files
mschwaigphiliptaron
authored andcommitted
add Vulkan support to Nix flake
1 parent e920ed3 commit 60ecf09

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

.devops/nix/package.nix

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@
1313
cudaPackages,
1414
darwin,
1515
rocmPackages,
16+
vulkan-headers,
17+
vulkan-loader,
1618
clblast,
1719
useBlas ? builtins.all (x: !x) [
1820
useCuda
1921
useMetalKit
2022
useOpenCL
2123
useRocm
24+
useVulkan
2225
],
2326
useCuda ? config.cudaSupport,
2427
useMetalKit ? stdenv.isAarch64 && stdenv.isDarwin && !useOpenCL,
2528
useMpi ? false, # Increases the runtime closure size by ~700M
2629
useOpenCL ? false,
2730
useRocm ? config.rocmSupport,
31+
useVulkan ? false,
2832
llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake
2933
}@inputs:
3034

@@ -48,7 +52,8 @@ let
4852
++ lib.optionals useMetalKit [ "MetalKit" ]
4953
++ lib.optionals useMpi [ "MPI" ]
5054
++ lib.optionals useOpenCL [ "OpenCL" ]
51-
++ lib.optionals useRocm [ "ROCm" ];
55+
++ lib.optionals useRocm [ "ROCm" ]
56+
++ lib.optionals useVulkan [ "Vulkan" ];
5257

5358
pnameSuffix =
5459
strings.optionalString (suffices != [ ])
@@ -108,6 +113,11 @@ let
108113
hipblas
109114
rocblas
110115
];
116+
117+
vulkanBuildInputs = [
118+
vulkan-headers
119+
vulkan-loader
120+
];
111121
in
112122

113123
effectiveStdenv.mkDerivation (
@@ -164,7 +174,8 @@ effectiveStdenv.mkDerivation (
164174
++ optionals useCuda cudaBuildInputs
165175
++ optionals useMpi [ mpi ]
166176
++ optionals useOpenCL [ clblast ]
167-
++ optionals useRocm rocmBuildInputs;
177+
++ optionals useRocm rocmBuildInputs
178+
++ optionals useVulkan vulkanBuildInputs;
168179

169180
cmakeFlags =
170181
[
@@ -178,6 +189,7 @@ effectiveStdenv.mkDerivation (
178189
(cmakeBool "LLAMA_HIPBLAS" useRocm)
179190
(cmakeBool "LLAMA_METAL" useMetalKit)
180191
(cmakeBool "LLAMA_MPI" useMpi)
192+
(cmakeBool "LLAMA_VULKAN" useVulkan)
181193
]
182194
++ optionals useCuda [
183195
(
@@ -218,6 +230,7 @@ effectiveStdenv.mkDerivation (
218230
useMpi
219231
useOpenCL
220232
useRocm
233+
useVulkan
221234
;
222235

223236
shell = mkShell {
@@ -242,11 +255,11 @@ effectiveStdenv.mkDerivation (
242255
# Configurations we don't want even the CI to evaluate. Results in the
243256
# "unsupported platform" messages. This is mostly a no-op, because
244257
# cudaPackages would've refused to evaluate anyway.
245-
badPlatforms = optionals (useCuda || useOpenCL) lib.platforms.darwin;
258+
badPlatforms = optionals (useCuda || useOpenCL || useVulkan) lib.platforms.darwin;
246259

247260
# Configurations that are known to result in build failures. Can be
248261
# overridden by importing Nixpkgs with `allowBroken = true`.
249-
broken = (useMetalKit && !effectiveStdenv.isDarwin);
262+
broken = (useMetalKit && !effectiveStdenv.isDarwin) || (useVulkan && effectiveStdenv.isDarwin);
250263

251264
description = "Inference of LLaMA model in pure C/C++${descriptionSuffix}";
252265
homepage = "https://github.com/ggerganov/llama.cpp/";

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157

158158
mpi-cpu = config.packages.default.override { useMpi = true; };
159159
mpi-cuda = config.packages.default.override { useMpi = true; };
160+
vulkan = config.packages.default.override { useVulkan = true; };
160161
}
161162
// lib.optionalAttrs (system == "x86_64-linux") {
162163
rocm = config.legacyPackages.llamaPackagesRocm.llama-cpp;

0 commit comments

Comments
 (0)