Skip to content

Commit 452acd8

Browse files
committed
nix: Added enableUma option
1 parent 74c4c9d commit 452acd8

File tree

1 file changed

+46
-45
lines changed

1 file changed

+46
-45
lines changed

.devops/nix/package.nix

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
enableCurl ? true,
3737
useVulkan ? false,
3838
buildAllCudaFaQuants ? false,
39+
enableUma ? false,
3940
llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake
4041

4142
# It's necessary to consistently use backendStdenv when building with CUDA support,
@@ -149,20 +150,19 @@ effectiveStdenv.mkDerivation (finalAttrs: {
149150
# see https://github.com/ggml-org/llama.cpp/pull/6118 for discussion
150151
__noChroot = effectiveStdenv.isDarwin && useMetalKit && precompileMetalShaders;
151152

152-
nativeBuildInputs =
153-
[
154-
cmake
155-
ninja
156-
pkg-config
157-
git
158-
]
159-
++ optionals useCuda [
160-
cudaPackages.cuda_nvcc
153+
nativeBuildInputs = [
154+
cmake
155+
ninja
156+
pkg-config
157+
git
158+
]
159+
++ optionals useCuda [
160+
cudaPackages.cuda_nvcc
161161

162-
autoAddDriverRunpath
163-
]
164-
++ optionals (effectiveStdenv.hostPlatform.isGnu && enableStatic) [ glibc.static ]
165-
++ optionals (effectiveStdenv.isDarwin && useMetalKit && precompileMetalShaders) [ xcrunHost ];
162+
autoAddDriverRunpath
163+
]
164+
++ optionals (effectiveStdenv.hostPlatform.isGnu && enableStatic) [ glibc.static ]
165+
++ optionals (effectiveStdenv.isDarwin && useMetalKit && precompileMetalShaders) [ xcrunHost ];
166166

167167
buildInputs =
168168
optionals effectiveStdenv.isDarwin darwinBuildInputs
@@ -174,39 +174,40 @@ effectiveStdenv.mkDerivation (finalAttrs: {
174174
++ optionals useVulkan vulkanBuildInputs
175175
++ optionals enableCurl [ curl ];
176176

177-
cmakeFlags =
178-
[
179-
(cmakeBool "LLAMA_BUILD_SERVER" true)
180-
(cmakeBool "BUILD_SHARED_LIBS" (!enableStatic))
181-
(cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
182-
(cmakeBool "LLAMA_CURL" enableCurl)
183-
(cmakeBool "GGML_NATIVE" false)
184-
(cmakeBool "GGML_BLAS" useBlas)
185-
(cmakeBool "GGML_CUDA" useCuda)
186-
(cmakeBool "GGML_HIP" useRocm)
187-
(cmakeBool "GGML_METAL" useMetalKit)
188-
(cmakeBool "GGML_VULKAN" useVulkan)
189-
(cmakeBool "GGML_STATIC" enableStatic)
190-
]
191-
++ optionals useCuda [
192-
(
193-
with cudaPackages.flags;
194-
cmakeFeature "CMAKE_CUDA_ARCHITECTURES" (
195-
builtins.concatStringsSep ";" (map dropDot cudaCapabilities)
196-
)
177+
cmakeFlags = [
178+
(cmakeBool "LLAMA_BUILD_SERVER" true)
179+
(cmakeBool "BUILD_SHARED_LIBS" (!enableStatic))
180+
(cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
181+
(cmakeBool "LLAMA_CURL" enableCurl)
182+
(cmakeBool "GGML_NATIVE" false)
183+
(cmakeBool "GGML_BLAS" useBlas)
184+
(cmakeBool "GGML_CUDA" useCuda)
185+
(cmakeBool "GGML_HIP" useRocm)
186+
(cmakeBool "GGML_METAL" useMetalKit)
187+
(cmakeBool "GGML_VULKAN" useVulkan)
188+
(cmakeBool "GGML_STATIC" enableStatic)
189+
]
190+
++ optionals useCuda [
191+
(
192+
with cudaPackages.flags;
193+
cmakeFeature "CMAKE_CUDA_ARCHITECTURES" (
194+
builtins.concatStringsSep ";" (map dropDot cudaCapabilities)
197195
)
198-
(cmakeBool "GGML_CUDA_FA_ALL_QUANTS" buildAllCudaFaQuants)
199-
]
200-
++ optionals useRocm [
201-
(cmakeFeature "CMAKE_HIP_COMPILER" "${rocmPackages.llvm.clang}/bin/clang")
202-
(cmakeFeature "AMDGPU_TARGETS" rocmGpuTargets)
203-
(cmakeBool "GGML_HIP_ROCWMMA_FATTN" rocmUseWmma)
204-
(cmakeBool "GGML_CUDA_FA_ALL_QUANTS" buildAllCudaFaQuants)
205-
]
206-
++ optionals useMetalKit [
207-
(lib.cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1")
208-
(cmakeBool "GGML_METAL_EMBED_LIBRARY" (!precompileMetalShaders))
209-
];
196+
)
197+
(cmakeBool "GGML_CUDA_FA_ALL_QUANTS" buildAllCudaFaQuants)
198+
(cmakeBool "GGML_CUDA_ENABLE_UNIFIED_MEMORY" enableUma)
199+
]
200+
++ optionals useRocm [
201+
(cmakeFeature "CMAKE_HIP_COMPILER" "${rocmPackages.llvm.clang}/bin/clang")
202+
(cmakeFeature "AMDGPU_TARGETS" rocmGpuTargets)
203+
(cmakeBool "GGML_HIP_ROCWMMA_FATTN" rocmUseWmma)
204+
(cmakeBool "GGML_CUDA_FA_ALL_QUANTS" buildAllCudaFaQuants)
205+
(cmakeBool "GGML_CUDA_ENABLE_UNIFIED_MEMORY" enableUma)
206+
]
207+
++ optionals useMetalKit [
208+
(lib.cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1")
209+
(cmakeBool "GGML_METAL_EMBED_LIBRARY" (!precompileMetalShaders))
210+
];
210211

211212
# Environment variables needed for ROCm
212213
env = optionalAttrs useRocm {

0 commit comments

Comments
 (0)