flake.nix: unclutter darwin support
This commit is contained in:
parent
b28426a952
commit
d73272f18b
2 changed files with 26 additions and 40 deletions
|
@ -1,17 +1,5 @@
|
||||||
final: prev:
|
final: prev:
|
||||||
|
|
||||||
let
|
|
||||||
inherit (final.stdenv) isAarch64 isDarwin;
|
|
||||||
|
|
||||||
darwinSpecific =
|
|
||||||
if isAarch64 then
|
|
||||||
{ inherit (final.darwin.apple_sdk_11_0.frameworks) Accelerate MetalKit; }
|
|
||||||
else
|
|
||||||
{ inherit (final.darwin.apple_sdk.frameworks) Accelerate CoreGraphics CoreVideo; };
|
|
||||||
|
|
||||||
osSpecific = if isDarwin then darwinSpecific else { };
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
{
|
||||||
llama-cpp = final.callPackage ./package.nix osSpecific;
|
llama-cpp = final.callPackage ./package.nix { };
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,18 @@
|
||||||
mpi,
|
mpi,
|
||||||
openblas, # TODO: Use the generic `blas` so users could switch betwen alternative implementations
|
openblas, # TODO: Use the generic `blas` so users could switch betwen alternative implementations
|
||||||
cudaPackages,
|
cudaPackages,
|
||||||
|
darwin,
|
||||||
rocmPackages,
|
rocmPackages,
|
||||||
clblast,
|
clblast,
|
||||||
Accelerate ? null,
|
useBlas ? builtins.all (x: !x) [
|
||||||
MetalKit ? null,
|
useCuda
|
||||||
CoreVideo ? null,
|
useMetalKit
|
||||||
CoreGraphics ? null,
|
useOpenCL
|
||||||
useOpenCL ? false,
|
useRocm
|
||||||
|
],
|
||||||
useCuda ? config.cudaSupport,
|
useCuda ? config.cudaSupport,
|
||||||
|
useMetalKit ? stdenv.isAarch64 && stdenv.isDarwin && !useOpenCL,
|
||||||
|
useOpenCL ? false,
|
||||||
useRocm ? config.rocmSupport,
|
useRocm ? config.rocmSupport,
|
||||||
}@inputs:
|
}@inputs:
|
||||||
|
|
||||||
|
@ -29,7 +33,6 @@ let
|
||||||
optionals
|
optionals
|
||||||
versionOlder
|
versionOlder
|
||||||
;
|
;
|
||||||
isDefault = !useOpenCL && !useCuda && !useRocm;
|
|
||||||
|
|
||||||
# It's necessary to consistently use backendStdenv when building with CUDA support,
|
# It's necessary to consistently use backendStdenv when building with CUDA support,
|
||||||
# otherwise we get libstdc++ errors downstream.
|
# otherwise we get libstdc++ errors downstream.
|
||||||
|
@ -44,7 +47,7 @@ let
|
||||||
" (CUDA accelerated)"
|
" (CUDA accelerated)"
|
||||||
else if useRocm then
|
else if useRocm then
|
||||||
" (ROCm accelerated)"
|
" (ROCm accelerated)"
|
||||||
else if (MetalKit != null) then
|
else if useMetalKit then
|
||||||
" (MetalKit accelerated)"
|
" (MetalKit accelerated)"
|
||||||
else
|
else
|
||||||
"";
|
"";
|
||||||
|
@ -70,13 +73,16 @@ let
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
# See ./overlay.nix for where these dependencies are passed in.
|
# apple_sdk is supposed to choose sane defaults, no need to handle isAarch64
|
||||||
defaultBuildInputs = builtins.filter (p: p != null) [
|
# separately
|
||||||
Accelerate
|
darwinBuildInputs =
|
||||||
MetalKit
|
with darwin.apple_sdk.frameworks;
|
||||||
CoreVideo
|
[ Accelerate ]
|
||||||
CoreGraphics
|
++ optionals useMetalKit [ MetalKit ]
|
||||||
];
|
++ optionals (!useMetalKit) [
|
||||||
|
CoreVideo
|
||||||
|
CoreGraphics
|
||||||
|
];
|
||||||
|
|
||||||
cudaBuildInputs = with cudaPackages; [
|
cudaBuildInputs = with cudaPackages; [
|
||||||
cuda_cccl.dev # <nv/target>
|
cuda_cccl.dev # <nv/target>
|
||||||
|
@ -121,7 +127,7 @@ effectiveStdenv.mkDerivation (finalAttrs: {
|
||||||
++ optionals useOpenCL [ clblast ]
|
++ optionals useOpenCL [ clblast ]
|
||||||
++ optionals useCuda cudaBuildInputs
|
++ optionals useCuda cudaBuildInputs
|
||||||
++ optionals useRocm rocmBuildInputs
|
++ optionals useRocm rocmBuildInputs
|
||||||
++ optionals isDefault defaultBuildInputs;
|
++ optionals effectiveStdenv.isDarwin darwinBuildInputs;
|
||||||
|
|
||||||
cmakeFlags =
|
cmakeFlags =
|
||||||
[
|
[
|
||||||
|
@ -129,6 +135,8 @@ effectiveStdenv.mkDerivation (finalAttrs: {
|
||||||
(cmakeBool "LLAMA_BUILD_SERVER" true)
|
(cmakeBool "LLAMA_BUILD_SERVER" true)
|
||||||
(cmakeBool "BUILD_SHARED_LIBS" true)
|
(cmakeBool "BUILD_SHARED_LIBS" true)
|
||||||
(cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
|
(cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
|
||||||
|
(cmakeBool "LLAMA_METAL" useMetalKit)
|
||||||
|
(cmakeBool "LLAMA_BLAS" useBlas)
|
||||||
]
|
]
|
||||||
++ optionals useOpenCL [ (cmakeBool "LLAMA_CLBLAST" true) ]
|
++ optionals useOpenCL [ (cmakeBool "LLAMA_CLBLAST" true) ]
|
||||||
++ optionals useCuda [ (cmakeBool "LLAMA_CUBLAS" true) ]
|
++ optionals useCuda [ (cmakeBool "LLAMA_CUBLAS" true) ]
|
||||||
|
@ -143,18 +151,8 @@ effectiveStdenv.mkDerivation (finalAttrs: {
|
||||||
# Should likely use `rocmPackages.clr.gpuTargets`.
|
# 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"
|
"-DAMDGPU_TARGETS=gfx803;gfx900;gfx906:xnack-;gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-;gfx940;gfx941;gfx942;gfx1010;gfx1012;gfx1030;gfx1100;gfx1101;gfx1102"
|
||||||
]
|
]
|
||||||
++ optionals isDefault (
|
++ optionals useMetalKit [ (lib.cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1") ]
|
||||||
if (MetalKit != null) then
|
++ optionals useBlas [ (lib.cmakeFeature "LLAMA_BLAS_VENDOR" "OpenBLAS") ];
|
||||||
[
|
|
||||||
"-DCMAKE_C_FLAGS=-D__ARM_FEATURE_DOTPROD=1"
|
|
||||||
"-DLLAMA_METAL=ON"
|
|
||||||
]
|
|
||||||
else
|
|
||||||
[
|
|
||||||
"-DLLAMA_BLAS=ON"
|
|
||||||
"-DLLAMA_BLAS_VENDOR=OpenBLAS"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
# TODO(SomeoneSerge): It's better to add proper install targets at the CMake level,
|
# TODO(SomeoneSerge): It's better to add proper install targets at the CMake level,
|
||||||
# if they haven't been added yet.
|
# if they haven't been added yet.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue