diff options
| -rw-r--r-- | machines/kusanagi/default.nix | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/machines/kusanagi/default.nix b/machines/kusanagi/default.nix index bb719d1..ff786f6 100644 --- a/machines/kusanagi/default.nix +++ b/machines/kusanagi/default.nix @@ -42,10 +42,14 @@ # --- Optical disc drives / archiving --- boot.kernelModules = [ "sg" ]; # for disc drive - # For disc drives + # For disc drives; plus systemd-tag the GPU compute nodes (kfd/renderD*) so + # ollama.service can order after them — char devices get no systemd device + # unit unless tagged. services.udev.extraRules = '' KERNEL=="sr[0-9]*", GROUP="cdrom", MODE="0660" KERNEL=="sg[0-9]*", GROUP="sg", MODE="0660" + SUBSYSTEM=="kfd", TAG+="systemd" + SUBSYSTEM=="drm", KERNEL=="renderD*", TAG+="systemd" ''; services.pcscd.enable = true; @@ -216,12 +220,11 @@ enable = true; package = pkgs.ollama-rocm; environmentVariables = { - HIP_VISIBLE_DEVICES = "0"; - # RDNA3 card reports as gfx1101/gfx1102/gfx11-generic, which the ROCm - # build bundled with ollama-rocm doesn't have kernels for -> it finds no - # usable device and silently runs 100% on CPU. Force it to present as - # gfx1100 (7900 XT/XTX), which is fully supported and binary-compatible. - HSA_OVERRIDE_GFX_VERSION = "11.0.0"; + # No HIP_VISIBLE_DEVICES / HSA_OVERRIDE_GFX_VERSION: the 7900 XT is + # native gfx1100 and discovery excludes the unsupported Raphael iGPU + # (gfx1036) on its own; ollama warns that overriding visible devices can + # itself break discovery. The past "runs 100% on CPU" incidents were the + # boot-order race handled below, not a gfx-target mismatch. # KV-cache quantization (below) is a no-op without flash attention; ollama # falls back to f16 KV cache, inflating VRAM use and forcing CPU offload. OLLAMA_FLASH_ATTENTION = "1"; @@ -230,6 +233,21 @@ }; }; + # ollama probes GPUs once at startup. At boot it raced amdgpu bring-up + # (started between /dev/kfd and the render node appearing) and permanently + # fell back to CPU. Order it after the tagged compute nodes (udev rules + # above) so discovery only runs once the card is really there. + systemd.services.ollama = { + wants = [ + "dev-kfd.device" + "dev-dri-renderD128.device" + ]; + after = [ + "dev-kfd.device" + "dev-dri-renderD128.device" + ]; + }; + services.immich = { enable = true; machine-learning.enable = false; |
