nixos/ollama: add vulkan acceleration option (#463430)

This commit is contained in:
Aleksana
2025-11-22 13:41:01 +00:00
committed by GitHub
4 changed files with 24 additions and 1 deletions
+2
View File
@@ -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 {
+1
View File
@@ -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;
+17
View File
@@ -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)
'';
}
+4 -1
View File
@@ -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 { }; };