job "ai-backend" { datacenters = ["Homelab-PTECH-DC"] region = "home" type = "service" group "ollama-group" { count = 1 # Pin to P52 Laptop (eGPU Host) constraint { attribute = "${meta.device}" value = "p52-laptop" } network { port "api" { static = 11434 } } task "ollama" { driver = "podman" env { OLLAMA_HOST = "0.0.0.0" OLLAMA_ORIGINS = "*" # 1. Force 6900XT Support HSA_OVERRIDE_GFX_VERSION = "10.3.0" # 2. Debugging OLLAMA_DEBUG = "1" } config { image = "docker.io/ollama/ollama:latest" ports = ["api"] # Required to talk to hardware (This handles most security opts) privileged = true # --- Explicit Device Mapping --- # Map the Compute interface and the Physical Card devices = [ "/dev/kfd", "/dev/dri/card1", "/dev/dri/renderD128" ] # --- Volumes --- volumes = [ # 1. Your Custom Storage Path "/mnt/local-ssd/nomad/stacks/ai/ai-backend/ollama:/root/.ollama", # 2. Shared Memory Workaround (Replaces ipc_mode = "host") # This helps the AMD driver communicate efficiently "/dev/shm:/dev/shm" ] } service { name = "ollama" port = "api" check { type = "http" path = "/" interval = "20s" timeout = "2s" } } resources { cpu = 2000 memory = 8192 # 8GB System RAM } } } }