diff --git a/nixos/modules/services/misc/ollama.nix b/nixos/modules/services/misc/ollama.nix index 6c45952b8ce7..9880da94e5c2 100644 --- a/nixos/modules/services/misc/ollama.nix +++ b/nixos/modules/services/misc/ollama.nix @@ -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 { diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 943b72ec614f..c43a410170a4 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -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; diff --git a/nixos/tests/ollama-vulkan.nix b/nixos/tests/ollama-vulkan.nix new file mode 100644 index 000000000000..c4f210ad26c8 --- /dev/null +++ b/nixos/tests/ollama-vulkan.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) + ''; +} diff --git a/pkgs/by-name/ol/ollama/package.nix b/pkgs/by-name/ol/ollama/package.nix index a386c5a81dca..2bb399e922cc 100644 --- a/pkgs/by-name/ol/ollama/package.nix +++ b/pkgs/by-name/ol/ollama/package.nix @@ -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 { }; };