ollama: add acceleration option
This commit is contained in:
parent
95827c16fe
commit
dade0fad68
1 changed files with 19 additions and 1 deletions
|
@ -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;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue