fix ollama for hass

This commit is contained in:
mjallen18
2024-06-10 09:08:54 -05:00
parent 239e477e66
commit f42575eb38
2 changed files with 16 additions and 21 deletions

View File

@@ -13,28 +13,21 @@ in
config = mkIf cfg.enable {
systemd.services.ollama-docker = {
path = [
pkgs.bash
pkgs.docker
virtualisation.oci-containers.containers.${cfg.name} = {
autoStart = true;
image = cfg.image;
extraOptions = [ "--device=nvidia.com/gpu=0" ];
volumes = [
"${cfg.configPath}:/root/.ollama"
];
script = ''
set -e
exec docker run \
--rm \
--gpus all \
--runtime=nvidia \
--name=${cfg.name} \
-e PUID=${cfg.puid} \
-e PGID=${cfg.pgid} \
-e TZ=${cfg.timeZone} \
-e 'NVIDIA_DRIVER_CAPABILITIES'='all' \
-e 'NVIDIA_VISIBLE_DEVICES'='all' \
-p ${cfg.port}:11434 \
-v '${cfg.configPath}:/root/.ollama' \
${cfg.image}:latest
'';
wantedBy = [ "multi-user.target" ];
ports = [ "${cfg.port}:11434" ];
environment = {
NVIDIA_VISIBLE_DEVICES = "all";
NVIDIA_DRIVER_CAPABILITIES = "all";
PUID = cfg.puid;
PGID = cfg.pgid;
TZ = cfg.timeZone;
};
};
};
}