*.nix: nixfmt
nix shell github:piegamesde/nixfmt/rfc101-style --command \ nixfmt flake.nix .devops/nix/*.nix
This commit is contained in:
parent
fea0239e24
commit
c8d39878d9
1 changed files with 82 additions and 80 deletions
|
@ -97,86 +97,88 @@ let
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
|
|
||||||
effectiveStdenv.mkDerivation (finalAttrs: {
|
effectiveStdenv.mkDerivation (
|
||||||
name = "llama.cpp";
|
finalAttrs: {
|
||||||
src = ../../.;
|
name = "llama.cpp";
|
||||||
meta = {
|
src = ../../.;
|
||||||
description = "Inference of LLaMA model in pure C/C++${descriptionSuffix}";
|
meta = {
|
||||||
mainProgram = "llama";
|
description = "Inference of LLaMA model in pure C/C++${descriptionSuffix}";
|
||||||
};
|
mainProgram = "llama";
|
||||||
|
|
||||||
postPatch = ''
|
|
||||||
substituteInPlace ./ggml-metal.m \
|
|
||||||
--replace '[bundle pathForResource:@"ggml-metal" ofType:@"metal"];' "@\"$out/bin/ggml-metal.metal\";"
|
|
||||||
|
|
||||||
# TODO: Package up each Python script or service appropriately.
|
|
||||||
# If we were to migrate to buildPythonPackage and prepare the `pyproject.toml`,
|
|
||||||
# we could make those *.py into setuptools' entrypoints
|
|
||||||
substituteInPlace ./*.py --replace "/usr/bin/env python" "${llama-python}/bin/python"
|
|
||||||
'';
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
cmake
|
|
||||||
ninja
|
|
||||||
pkg-config
|
|
||||||
git
|
|
||||||
] ++ optionals useCuda [ cudaPackages.cuda_nvcc ];
|
|
||||||
|
|
||||||
buildInputs =
|
|
||||||
[ mpi ]
|
|
||||||
++ optionals useOpenCL [ clblast ]
|
|
||||||
++ optionals useCuda cudaBuildInputs
|
|
||||||
++ optionals useRocm rocmBuildInputs
|
|
||||||
++ optionals effectiveStdenv.isDarwin darwinBuildInputs;
|
|
||||||
|
|
||||||
cmakeFlags =
|
|
||||||
[
|
|
||||||
(cmakeBool "LLAMA_NATIVE" true)
|
|
||||||
(cmakeBool "LLAMA_BUILD_SERVER" true)
|
|
||||||
(cmakeBool "BUILD_SHARED_LIBS" true)
|
|
||||||
(cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
|
|
||||||
(cmakeBool "LLAMA_METAL" useMetalKit)
|
|
||||||
(cmakeBool "LLAMA_BLAS" useBlas)
|
|
||||||
]
|
|
||||||
++ optionals useOpenCL [ (cmakeBool "LLAMA_CLBLAST" true) ]
|
|
||||||
++ optionals useCuda [ (cmakeBool "LLAMA_CUBLAS" true) ]
|
|
||||||
++ optionals useRocm [
|
|
||||||
(cmakeBool "LLAMA_HIPBLAS" true)
|
|
||||||
(cmakeFeature "CMAKE_C_COMPILER" "hipcc")
|
|
||||||
(cmakeFeature "CMAKE_CXX_COMPILER" "hipcc")
|
|
||||||
|
|
||||||
# Build all targets supported by rocBLAS. When updating search for TARGET_LIST_ROCM
|
|
||||||
# in https://github.com/ROCmSoftwarePlatform/rocBLAS/blob/develop/CMakeLists.txt
|
|
||||||
# and select the line that matches the current nixpkgs version of rocBLAS.
|
|
||||||
# Should likely use `rocmPackages.clr.gpuTargets`.
|
|
||||||
"-DAMDGPU_TARGETS=gfx803;gfx900;gfx906:xnack-;gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-;gfx940;gfx941;gfx942;gfx1010;gfx1012;gfx1030;gfx1100;gfx1101;gfx1102"
|
|
||||||
]
|
|
||||||
++ optionals useMetalKit [ (lib.cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1") ]
|
|
||||||
++ optionals useBlas [ (lib.cmakeFeature "LLAMA_BLAS_VENDOR" "OpenBLAS") ];
|
|
||||||
|
|
||||||
# TODO(SomeoneSerge): It's better to add proper install targets at the CMake level,
|
|
||||||
# if they haven't been added yet.
|
|
||||||
postInstall = ''
|
|
||||||
mv $out/bin/main $out/bin/llama
|
|
||||||
mv $out/bin/server $out/bin/llama-server
|
|
||||||
mkdir -p $out/include
|
|
||||||
cp $src/llama.h $out/include/
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Define the shells here, but don't add in the inputsFrom to avoid recursion.
|
|
||||||
passthru = {
|
|
||||||
shell = mkShell {
|
|
||||||
name = "default${descriptionSuffix}";
|
|
||||||
description = "contains numpy and sentencepiece";
|
|
||||||
buildInputs = [ llama-python ];
|
|
||||||
inputsFrom = [ finalAttrs.finalPackage ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
shell-extra = mkShell {
|
postPatch = ''
|
||||||
name = "extra${descriptionSuffix}";
|
substituteInPlace ./ggml-metal.m \
|
||||||
description = "contains numpy, sentencepiece, torchWithoutCuda, and transformers";
|
--replace '[bundle pathForResource:@"ggml-metal" ofType:@"metal"];' "@\"$out/bin/ggml-metal.metal\";"
|
||||||
buildInputs = [ llama-python-extra ];
|
|
||||||
inputsFrom = [ finalAttrs.finalPackage ];
|
# TODO: Package up each Python script or service appropriately.
|
||||||
|
# If we were to migrate to buildPythonPackage and prepare the `pyproject.toml`,
|
||||||
|
# we could make those *.py into setuptools' entrypoints
|
||||||
|
substituteInPlace ./*.py --replace "/usr/bin/env python" "${llama-python}/bin/python"
|
||||||
|
'';
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
cmake
|
||||||
|
ninja
|
||||||
|
pkg-config
|
||||||
|
git
|
||||||
|
] ++ optionals useCuda [ cudaPackages.cuda_nvcc ];
|
||||||
|
|
||||||
|
buildInputs =
|
||||||
|
[ mpi ]
|
||||||
|
++ optionals useOpenCL [ clblast ]
|
||||||
|
++ optionals useCuda cudaBuildInputs
|
||||||
|
++ optionals useRocm rocmBuildInputs
|
||||||
|
++ optionals effectiveStdenv.isDarwin darwinBuildInputs;
|
||||||
|
|
||||||
|
cmakeFlags =
|
||||||
|
[
|
||||||
|
(cmakeBool "LLAMA_NATIVE" true)
|
||||||
|
(cmakeBool "LLAMA_BUILD_SERVER" true)
|
||||||
|
(cmakeBool "BUILD_SHARED_LIBS" true)
|
||||||
|
(cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
|
||||||
|
(cmakeBool "LLAMA_METAL" useMetalKit)
|
||||||
|
(cmakeBool "LLAMA_BLAS" useBlas)
|
||||||
|
]
|
||||||
|
++ optionals useOpenCL [ (cmakeBool "LLAMA_CLBLAST" true) ]
|
||||||
|
++ optionals useCuda [ (cmakeBool "LLAMA_CUBLAS" true) ]
|
||||||
|
++ optionals useRocm [
|
||||||
|
(cmakeBool "LLAMA_HIPBLAS" true)
|
||||||
|
(cmakeFeature "CMAKE_C_COMPILER" "hipcc")
|
||||||
|
(cmakeFeature "CMAKE_CXX_COMPILER" "hipcc")
|
||||||
|
|
||||||
|
# Build all targets supported by rocBLAS. When updating search for TARGET_LIST_ROCM
|
||||||
|
# in https://github.com/ROCmSoftwarePlatform/rocBLAS/blob/develop/CMakeLists.txt
|
||||||
|
# and select the line that matches the current nixpkgs version of rocBLAS.
|
||||||
|
# Should likely use `rocmPackages.clr.gpuTargets`.
|
||||||
|
"-DAMDGPU_TARGETS=gfx803;gfx900;gfx906:xnack-;gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-;gfx940;gfx941;gfx942;gfx1010;gfx1012;gfx1030;gfx1100;gfx1101;gfx1102"
|
||||||
|
]
|
||||||
|
++ optionals useMetalKit [ (lib.cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1") ]
|
||||||
|
++ optionals useBlas [ (lib.cmakeFeature "LLAMA_BLAS_VENDOR" "OpenBLAS") ];
|
||||||
|
|
||||||
|
# TODO(SomeoneSerge): It's better to add proper install targets at the CMake level,
|
||||||
|
# if they haven't been added yet.
|
||||||
|
postInstall = ''
|
||||||
|
mv $out/bin/main $out/bin/llama
|
||||||
|
mv $out/bin/server $out/bin/llama-server
|
||||||
|
mkdir -p $out/include
|
||||||
|
cp $src/llama.h $out/include/
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Define the shells here, but don't add in the inputsFrom to avoid recursion.
|
||||||
|
passthru = {
|
||||||
|
shell = mkShell {
|
||||||
|
name = "default${descriptionSuffix}";
|
||||||
|
description = "contains numpy and sentencepiece";
|
||||||
|
buildInputs = [ llama-python ];
|
||||||
|
inputsFrom = [ finalAttrs.finalPackage ];
|
||||||
|
};
|
||||||
|
|
||||||
|
shell-extra = mkShell {
|
||||||
|
name = "extra${descriptionSuffix}";
|
||||||
|
description = "contains numpy, sentencepiece, torchWithoutCuda, and transformers";
|
||||||
|
buildInputs = [ llama-python-extra ];
|
||||||
|
inputsFrom = [ finalAttrs.finalPackage ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
})
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue