1
1
Fork 0

ollama: add acceleration option

This commit is contained in:
Myned 2025-04-02 09:37:56 -05:00
parent 95827c16fe
commit dade0fad68
Signed by: myned
GPG key ID: C7224454F7881A34

View file

@ -9,6 +9,11 @@ in {
options.custom.services.ollama = { options.custom.services.ollama = {
enable = mkEnableOption "ollama"; enable = mkEnableOption "ollama";
acceleration = mkOption {
default = config.custom.full;
type = types.bool;
};
download = mkOption { download = mkOption {
default = null; default = null;
type = with types; nullOr (enum ["low" "medium" "high"]); type = with types; nullOr (enum ["low" "medium" "high"]);
@ -20,7 +25,7 @@ in {
then "localhost" then "localhost"
else "mynix"; else "mynix";
type = with types; str; type = types.str;
}; };
}; };
@ -30,6 +35,18 @@ in {
services.ollama = { services.ollama = {
enable = true; 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 # 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 # https://github.com/ollama/ollama/blob/main/docs/faq.md#how-can-i-expose-ollama-on-my-network
host = "0.0.0.0"; host = "0.0.0.0";
@ -71,6 +88,7 @@ in {
# https://wiki.nixos.org/wiki/Ollama#AMD_GPU_with_open_source_driver # https://wiki.nixos.org/wiki/Ollama#AMD_GPU_with_open_source_driver
# https://github.com/ollama/ollama/blob/main/docs/gpu.md#overrides # https://github.com/ollama/ollama/blob/main/docs/gpu.md#overrides
#?? nix run nixpkgs#rocmPackages.rocminfo | grep gfx #?? nix run nixpkgs#rocmPackages.rocminfo | grep gfx
#?? echo $HSA_OVERRIDE_GFX_VERSION
rocmOverrideGfx = with config.custom.settings.hardware; mkIf (isString rocm) rocm; rocmOverrideGfx = with config.custom.settings.hardware; mkIf (isString rocm) rocm;
}; };
}; };