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 = {
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;
};
};