nixos/ollama: add vulkan acceleration option (#463430)
This commit is contained in:
@@ -103,6 +103,7 @@ in
|
||||
false
|
||||
"rocm"
|
||||
"cuda"
|
||||
"vulkan"
|
||||
]
|
||||
);
|
||||
default = null;
|
||||
@@ -119,6 +120,7 @@ in
|
||||
- may require overriding gpu type with `services.ollama.rocmOverrideGfx`
|
||||
if rocm doesn't detect your AMD gpu
|
||||
- `"cuda"`: supported by most modern NVIDIA GPUs
|
||||
- `"vulkan"`: supported by most modern GPUs on Linux
|
||||
'';
|
||||
};
|
||||
rocmOverrideGfx = lib.mkOption {
|
||||
|
||||
@@ -1145,6 +1145,7 @@ in
|
||||
ollama = runTest ./ollama.nix;
|
||||
ollama-cuda = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./ollama-cuda.nix;
|
||||
ollama-rocm = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./ollama-rocm.nix;
|
||||
ollama-vulkan = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./ollama-vulkan.nix;
|
||||
ombi = runTest ./ombi.nix;
|
||||
omnom = runTest ./omnom;
|
||||
oncall = runTest ./web-apps/oncall.nix;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
name = "ollama-vulkan";
|
||||
meta.maintainers = with lib.maintainers; [ abysssol ];
|
||||
|
||||
nodes.vulkan =
|
||||
{ ... }:
|
||||
{
|
||||
services.ollama.enable = true;
|
||||
services.ollama.acceleration = "vulkan";
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
vulkan.wait_for_unit("multi-user.target")
|
||||
vulkan.wait_for_open_port(11434)
|
||||
'';
|
||||
}
|
||||
@@ -32,6 +32,7 @@
|
||||
ollama,
|
||||
ollama-rocm,
|
||||
ollama-cuda,
|
||||
ollama-vulkan,
|
||||
|
||||
config,
|
||||
# one of `[ null false "rocm" "cuda" "vulkan" ]`
|
||||
@@ -119,6 +120,7 @@ let
|
||||
]
|
||||
++ lib.optionals enableVulkan [
|
||||
"--suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath (map lib.getLib vulkanLibs)}'"
|
||||
"--set-default OLLAMA_VULKAN : '1'"
|
||||
];
|
||||
wrapperArgs = builtins.concatStringsSep " " wrapperOptions;
|
||||
|
||||
@@ -268,10 +270,11 @@ goBuild (finalAttrs: {
|
||||
inherit ollama;
|
||||
}
|
||||
// lib.optionalAttrs stdenv.hostPlatform.isLinux {
|
||||
inherit ollama-rocm ollama-cuda;
|
||||
inherit ollama-rocm ollama-cuda ollama-vulkan;
|
||||
service = nixosTests.ollama;
|
||||
service-cuda = nixosTests.ollama-cuda;
|
||||
service-rocm = nixosTests.ollama-rocm;
|
||||
service-vulkan = nixosTests.ollama-vulkan;
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs (!enableRocm && !enableCuda) { updateScript = nix-update-script { }; };
|
||||
|
||||
Reference in New Issue
Block a user