Skip to content

Commit 61d1a28

Browse files
authored
flake.nix : add rocm support and cleanup (#2808)
1 parent 741ca7d commit 61d1a28

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
outputs = { self, nixpkgs, flake-utils }:
77
flake-utils.lib.eachDefaultSystem (system:
88
let
9+
name = "llama.cpp";
10+
src = ./.;
11+
meta.mainProgram = "llama";
912
inherit (pkgs.stdenv) isAarch32 isAarch64 isDarwin;
1013
buildInputs = with pkgs; [ openmpi ];
1114
osSpecific = with pkgs; buildInputs ++
@@ -31,7 +34,7 @@
3134
with pkgs; [ openblas ]
3235
);
3336
pkgs = import nixpkgs { inherit system; };
34-
nativeBuildInputs = with pkgs; [ cmake pkgconfig ];
37+
nativeBuildInputs = with pkgs; [ cmake ninja pkgconfig ];
3538
llama-python =
3639
pkgs.python3.withPackages (ps: with ps; [ numpy sentencepiece ]);
3740
postPatch = ''
@@ -44,35 +47,35 @@
4447
mv $out/bin/server $out/bin/llama-server
4548
'';
4649
cmakeFlags = [ "-DLLAMA_BUILD_SERVER=ON" "-DLLAMA_MPI=ON" "-DBUILD_SHARED_LIBS=ON" "-DCMAKE_SKIP_BUILD_RPATH=ON" ];
47-
in {
50+
in
51+
{
4852
packages.default = pkgs.stdenv.mkDerivation {
49-
name = "llama.cpp";
50-
src = ./.;
51-
postPatch = postPatch;
52-
nativeBuildInputs = nativeBuildInputs;
53-
buildInputs = osSpecific;
53+
inherit name src meta postPatch nativeBuildInputs buildInputs postInstall;
5454
cmakeFlags = cmakeFlags
5555
++ (if isAarch64 && isDarwin then [
56-
"-DCMAKE_C_FLAGS=-D__ARM_FEATURE_DOTPROD=1"
57-
"-DLLAMA_METAL=ON"
58-
] else [
59-
"-DLLAMA_BLAS=ON"
60-
"-DLLAMA_BLAS_VENDOR=OpenBLAS"
56+
"-DCMAKE_C_FLAGS=-D__ARM_FEATURE_DOTPROD=1"
57+
"-DLLAMA_METAL=ON"
58+
] else [
59+
"-DLLAMA_BLAS=ON"
60+
"-DLLAMA_BLAS_VENDOR=OpenBLAS"
6161
]);
62-
postInstall = postInstall;
63-
meta.mainProgram = "llama";
6462
};
6563
packages.opencl = pkgs.stdenv.mkDerivation {
66-
name = "llama.cpp";
67-
src = ./.;
68-
postPatch = postPatch;
69-
nativeBuildInputs = nativeBuildInputs;
64+
inherit name src meta postPatch nativeBuildInputs postInstall;
7065
buildInputs = with pkgs; buildInputs ++ [ clblast ];
7166
cmakeFlags = cmakeFlags ++ [
7267
"-DLLAMA_CLBLAST=ON"
7368
];
74-
postInstall = postInstall;
75-
meta.mainProgram = "llama";
69+
};
70+
packages.rocm = pkgs.stdenv.mkDerivation {
71+
inherit name src meta postPatch nativeBuildInputs postInstall;
72+
buildInputs = with pkgs; buildInputs ++ [ hip hipblas rocblas ];
73+
cmakeFlags = cmakeFlags ++ [
74+
"-DLLAMA_HIPBLAS=1"
75+
"-DCMAKE_C_COMPILER=hipcc"
76+
"-DCMAKE_CXX_COMPILER=hipcc"
77+
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
78+
];
7679
};
7780
apps.llama-server = {
7881
type = "app";

0 commit comments

Comments
 (0)