summaryrefslogtreecommitdiff
path: root/Biz/Bild/Deps/llama-cpp.nix
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2023-08-10 21:11:23 -0400
committerBen Sima <ben@bsima.me>2023-08-16 14:29:43 -0400
commit247678afc7c74c98f64e8d19f67355d128946974 (patch)
tree6bde2696aab9029f67ff6eb136f26b81bcd5a4c4 /Biz/Bild/Deps/llama-cpp.nix
parent4e67ef22a7508150798413081bf8a5bb4adab6e5 (diff)
Add llama-cpp and exllama
Diffstat (limited to 'Biz/Bild/Deps/llama-cpp.nix')
-rw-r--r--Biz/Bild/Deps/llama-cpp.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/Biz/Bild/Deps/llama-cpp.nix b/Biz/Bild/Deps/llama-cpp.nix
new file mode 100644
index 0000000..85bd778
--- /dev/null
+++ b/Biz/Bild/Deps/llama-cpp.nix
@@ -0,0 +1,41 @@
+{ stdenv
+, pkgs
+, sources
+, python3
+, cmake
+, pkgconfig
+, openmpi
+, cudaPackages
+}:
+let
+ llama-python = python3.withPackages (ps: with ps; [ numpy sentencepiece ]);
+in stdenv.mkDerivation {
+ name = "llama.cpp";
+ version = sources.llama-cpp.rev;
+
+ src = sources.llama-cpp;
+
+ postPatch = ''
+ substituteInPlace ./ggml-metal.m \
+ --replace '[bundle pathForResource:@"ggml-metal" ofType:@"metal"];' "@\"$out/bin/ggml-metal.metal\";"
+ substituteInPlace ./*.py --replace '/usr/bin/env python' '${llama-python}/bin/python'
+ '';
+
+ nativeBuildInputs = [ cmake pkgconfig ];
+ buildInputs = [ openmpi cudaPackages.cudatoolkit ];
+
+ cmakeFlags = [
+ "-DLLAMA_BUILD_SERVER=ON"
+ "-DLLAMA_MPI=ON"
+ "-DBUILD_SHARED_LIBS=ON"
+ "-DCMAKE_SKIP_BUILD_RPATH=ON"
+ "-DLLAMA_CUBLAS=ON"
+ ];
+
+ postInstall = ''
+ mv $out/bin/main $out/bin/llama
+ mv $out/bin/server $out/bin/llama-server
+ '';
+
+ meta.mainProgram = "llama";
+}