summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schwaighofer <mschwaig@users.noreply.github.com>2024-01-28 12:59:43 +0100
committerPhilip Taron <philip.taron@gmail.com>2024-02-03 13:13:07 -0600
commit60ecf099eddfe70fec797ef6790572e452054add (patch)
treeb9230182686ff9f27f67e53713bf8a1fdd109063
parente920ed393d989ed35625ddaf182ebb52cda07fcd (diff)
add Vulkan support to Nix flake
-rw-r--r--.devops/nix/package.nix21
-rw-r--r--flake.nix1
2 files changed, 18 insertions, 4 deletions
diff --git a/.devops/nix/package.nix b/.devops/nix/package.nix
index a868a9a6..ad23f7dd 100644
--- a/.devops/nix/package.nix
+++ b/.devops/nix/package.nix
@@ -13,18 +13,22 @@
cudaPackages,
darwin,
rocmPackages,
+ vulkan-headers,
+ vulkan-loader,
clblast,
useBlas ? builtins.all (x: !x) [
useCuda
useMetalKit
useOpenCL
useRocm
+ useVulkan
],
useCuda ? config.cudaSupport,
useMetalKit ? stdenv.isAarch64 && stdenv.isDarwin && !useOpenCL,
useMpi ? false, # Increases the runtime closure size by ~700M
useOpenCL ? false,
useRocm ? config.rocmSupport,
+ useVulkan ? false,
llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake
}@inputs:
@@ -48,7 +52,8 @@ let
++ lib.optionals useMetalKit [ "MetalKit" ]
++ lib.optionals useMpi [ "MPI" ]
++ lib.optionals useOpenCL [ "OpenCL" ]
- ++ lib.optionals useRocm [ "ROCm" ];
+ ++ lib.optionals useRocm [ "ROCm" ]
+ ++ lib.optionals useVulkan [ "Vulkan" ];
pnameSuffix =
strings.optionalString (suffices != [ ])
@@ -108,6 +113,11 @@ let
hipblas
rocblas
];
+
+ vulkanBuildInputs = [
+ vulkan-headers
+ vulkan-loader
+ ];
in
effectiveStdenv.mkDerivation (
@@ -164,7 +174,8 @@ effectiveStdenv.mkDerivation (
++ optionals useCuda cudaBuildInputs
++ optionals useMpi [ mpi ]
++ optionals useOpenCL [ clblast ]
- ++ optionals useRocm rocmBuildInputs;
+ ++ optionals useRocm rocmBuildInputs
+ ++ optionals useVulkan vulkanBuildInputs;
cmakeFlags =
[
@@ -178,6 +189,7 @@ effectiveStdenv.mkDerivation (
(cmakeBool "LLAMA_HIPBLAS" useRocm)
(cmakeBool "LLAMA_METAL" useMetalKit)
(cmakeBool "LLAMA_MPI" useMpi)
+ (cmakeBool "LLAMA_VULKAN" useVulkan)
]
++ optionals useCuda [
(
@@ -218,6 +230,7 @@ effectiveStdenv.mkDerivation (
useMpi
useOpenCL
useRocm
+ useVulkan
;
shell = mkShell {
@@ -242,11 +255,11 @@ effectiveStdenv.mkDerivation (
# Configurations we don't want even the CI to evaluate. Results in the
# "unsupported platform" messages. This is mostly a no-op, because
# cudaPackages would've refused to evaluate anyway.
- badPlatforms = optionals (useCuda || useOpenCL) lib.platforms.darwin;
+ badPlatforms = optionals (useCuda || useOpenCL || useVulkan) lib.platforms.darwin;
# Configurations that are known to result in build failures. Can be
# overridden by importing Nixpkgs with `allowBroken = true`.
- broken = (useMetalKit && !effectiveStdenv.isDarwin);
+ broken = (useMetalKit && !effectiveStdenv.isDarwin) || (useVulkan && effectiveStdenv.isDarwin);
description = "Inference of LLaMA model in pure C/C++${descriptionSuffix}";
homepage = "https://github.com/ggerganov/llama.cpp/";
diff --git a/flake.nix b/flake.nix
index a776ba02..ad2f9b29 100644
--- a/flake.nix
+++ b/flake.nix
@@ -157,6 +157,7 @@
mpi-cpu = config.packages.default.override { useMpi = true; };
mpi-cuda = config.packages.default.override { useMpi = true; };
+ vulkan = config.packages.default.override { useVulkan = true; };
}
// lib.optionalAttrs (system == "x86_64-linux") {
rocm = config.legacyPackages.llamaPackagesRocm.llama-cpp;