From dade0fad68bd084ae3caf9b88b076f7bd1db27e0 Mon Sep 17 00:00:00 2001 From: Myned <dev@bjork.tech> Date: Wed, 2 Apr 2025 09:37:56 -0500 Subject: [PATCH] ollama: add acceleration option --- options/custom/services/ollama.nix | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/options/custom/services/ollama.nix b/options/custom/services/ollama.nix index 680a51b..7f384db 100644 --- a/options/custom/services/ollama.nix +++ b/options/custom/services/ollama.nix @@ -9,6 +9,11 @@ in { options.custom.services.ollama = { enable = mkEnableOption "ollama"; + acceleration = mkOption { + default = config.custom.full; + type = types.bool; + }; + download = mkOption { default = null; type = with types; nullOr (enum ["low" "medium" "high"]); @@ -20,7 +25,7 @@ in { then "localhost" else "mynix"; - type = with types; str; + type = types.str; }; }; @@ -30,6 +35,18 @@ in { services.ollama = { enable = true; + acceleration = + if cfg.acceleration + then + ( + if config.custom.settings.hardware.gpu == "amd" + then "rocm" + else if config.custom.settings.hardware.gpu == "nvidia" + then "cuda" + else null + ) + else false; # CPU + # Bind to all interfaces, but only Tailscale can access the closed port # https://github.com/ollama/ollama/blob/main/docs/faq.md#how-can-i-expose-ollama-on-my-network host = "0.0.0.0"; @@ -71,6 +88,7 @@ in { # https://wiki.nixos.org/wiki/Ollama#AMD_GPU_with_open_source_driver # https://github.com/ollama/ollama/blob/main/docs/gpu.md#overrides #?? nix run nixpkgs#rocmPackages.rocminfo | grep gfx + #?? echo $HSA_OVERRIDE_GFX_VERSION rocmOverrideGfx = with config.custom.settings.hardware; mkIf (isString rocm) rocm; }; };