From 2db973e69ea03b67008a267dd613255dbe75d50e Mon Sep 17 00:00:00 2001 From: Niklas Korz Date: Sun, 12 Mar 2023 10:15:46 +0100 Subject: [PATCH 1/2] Nix flake --- flake.lock | 43 +++++++++++++++++++++++++++++++++++++++++++ flake.nix | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..343996d --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1678470307, + "narHash": "sha256-OEeMUr3ueLIXyW/OaFUX5jUdimyQwMg/7e+/Q0gC/QE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0c4800d579af4ed98ecc47d464a5e7b0870c4b1f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d709aa5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + python = with pkgs; python310.withPackages (ps: with python310Packages; [ + torch + numpy + sentencepiece + ]); + in + { + packages.default = pkgs.stdenv.mkDerivation { + name = "llama.cpp"; + buildInputs = [ + pkgs.darwin.apple_sdk.frameworks.Accelerate + ]; + src = ./.; + installPhase = '' + mkdir -p $out/bin + mv main $out/bin/llama-cpp + mv quantize $out/bin/llama-cpp-quantize + echo "#!${python}/bin/python" > $out/bin/convert-pth-to-ggml + cat convert-pth-to-ggml.py >> $out/bin/convert-pth-to-ggml + chmod +x $out/bin/convert-pth-to-ggml + ''; + }; + } + ); +} From d6b663f30c0815e90bdfbbcfe346d0005c6ea130 Mon Sep 17 00:00:00 2001 From: Niklas Korz Date: Mon, 13 Mar 2023 10:23:53 +0100 Subject: [PATCH 2/2] Nix: only add Accelerate framework on macOS Co-authored-by: Pavol Rusnak --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index d709aa5..6029375 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ { packages.default = pkgs.stdenv.mkDerivation { name = "llama.cpp"; - buildInputs = [ + buildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.darwin.apple_sdk.frameworks.Accelerate ]; src = ./.;