From 3e14442811fb525d6ed818a18f2ab28bc03d63f5 Mon Sep 17 00:00:00 2001 From: mad9home <26679496+mad9home@users.noreply.github.com> Date: Tue, 6 Oct 2026 13:25:41 +0200 Subject: [PATCH] docker: GGUF_DIR, RESIDENT_BUDGET_GIB and KV_STREAMING env vars; document the stop timeout - GGUF_DIR passes setup's --gguf-dir, so a container can use model files the host already has instead of downloading them again (#252/#444 cover the native setup only) - RESIDENT_BUDGET_GIB and KV_STREAMING pass --resident-budget-gib and --kv-streaming; unset keeps setup's own defaults - INSTALL.md: a mounted GGUF folder must be writable on the first start (the Unsloth SHA-256 result is kept as .done next to each shard) - INSTALL.md: releasing tens of GB of page-locked RAM on SIGTERM takes longer than Docker's 10 s default; without --stop-timeout the container is killed (exit 137) The INSTALL.md paragraph was added by hand (the PR's numbered list no longer exists); KV_STREAMING maps to setup's current --kv-streaming auto|on|off. (PR #491) --- Dockerfile | 3 ++- docker-entrypoint.sh | 12 +++++++++++- docs/INSTALL.md | 9 +++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6b62dae0..a95d47e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,8 @@ # # Setup choices are env vars, read by docker-entrypoint.sh: FAMILY, MODEL, CONTEXT, # VISION (no | yes | cpu), KV (int8 | q4_0 | k8v4), GPU (one card) or GPUS ("0,2" -# or "all", with LAYER_SPLIT), LOW_RAM (auto | on | off), HOST, PORT, API_KEY. +# or "all", with LAYER_SPLIT), LOW_RAM (auto | on | off), HOST, PORT, API_KEY, +# GGUF_DIR (GGUF files you already have), RESIDENT_BUDGET_GIB, KV_STREAMING. # # Only the model files, the prepared pack, the MTP layer and the install config # live in the /data volume; the engine is part of the image. Strata loads 32-62 GB diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index f167bed0..d20ccdc9 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -19,6 +19,9 @@ GPUS="${GPUS:-}" # "0,2" or "all": one model across several cards GPU="${GPU:-}" # one card, numbered as nvidia-smi numbers them LAYER_SPLIT="${LAYER_SPLIT:-}" # with GPUS: where each later card's layers start (default: auto) LOW_RAM="${LOW_RAM:-auto}" # on: the experts come from the pack's experts.bin, not from RAM +GGUF_DIR="${GGUF_DIR:-}" # a mounted folder with GGUF files you already have: no download +RESIDENT_BUDGET_GIB="${RESIDENT_BUDGET_GIB:-}" # UD-Q4_K_XL: GiB of experts kept in RAM (default: setup's pick) +KV_STREAMING="${KV_STREAMING:-}" # auto | on | off; empty: setup.py's own default (auto) # setup.py starts the newest strata-*.json it finds, so link in exactly the one # this family and model were set up with. The config is the recorded output of @@ -38,7 +41,11 @@ mkdir -p "$STRATA_DATA/config" # from /proc/meminfo, which in a container is the host's total, not the container's # limit, so a memory-capped container has to ask for the low-RAM mode itself. if [ "${REINSTALL:-0}" = "1" ] || [ ! -f "$cfg" ]; then - echo "Setting up $tag: downloading the model (~70 GB; the engine is already in the image)." + if [ -n "$GGUF_DIR" ]; then + echo "Setting up $tag from the GGUF files in $GGUF_DIR (the engine is already in the image)." + else + echo "Setting up $tag: downloading the model (~70 GB; the engine is already in the image)." + fi set -- --family "$FAMILY" --model "$MODEL" --context "$CONTEXT" --vision "$VISION" \ --data-dir "$STRATA_DATA" --host "$HOST" --api-key "$API_KEY" \ --port "$PORT" --no-start --low-ram "$LOW_RAM" @@ -46,6 +53,9 @@ if [ "${REINSTALL:-0}" = "1" ] || [ ! -f "$cfg" ]; then if [ -n "$GPUS" ]; then set -- "$@" --gpus "$GPUS"; fi if [ -n "$GPU" ]; then set -- "$@" --gpu "$GPU"; fi if [ -n "$LAYER_SPLIT" ]; then set -- "$@" --layer-split "$LAYER_SPLIT"; fi + if [ -n "$GGUF_DIR" ]; then set -- "$@" --gguf-dir "$GGUF_DIR"; fi + if [ -n "$RESIDENT_BUDGET_GIB" ]; then set -- "$@" --resident-budget-gib "$RESIDENT_BUDGET_GIB"; fi + if [ -n "$KV_STREAMING" ]; then set -- "$@" --kv-streaming "$KV_STREAMING"; fi .venv/bin/python setup.py --setup --yes "$@" [ -e "/opt/strata/strata-$tag.json" ] && { cmp -s "/opt/strata/strata-$tag.json" "$cfg" || cp -f "/opt/strata/strata-$tag.json" "$cfg"; } else diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 05b1035d..fb1f32fd 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -120,6 +120,15 @@ The same idea, in a container (NVIDIA cards). The server listens on `0.0.0.0:8080` by default; set `-e API_KEY=` before exposing the port to a network. The image has a `HEALTHCHECK` on `/health`, so `docker ps` shows the container healthy once the model is loaded, and `GET /v1/status` says what it is running. + Model files you already have (setup's `--gguf-dir`): mount their folder and name it, e.g. + `-v /models/UD-Q4_K_XL:/gguf -e GGUF_DIR=/gguf -e FAMILY=unsloth -e MODEL=UD-Q4_K_XL`. + Mount it writable for the first start: setup checks the Unsloth file's SHA-256 once and keeps the + result as `.done` next to each shard; later starts skip setup, so `:ro` is fine then. + `-e RESIDENT_BUDGET_GIB=N` and `-e KV_STREAMING=on|off|auto` pass setup's `--resident-budget-gib` + and `--kv-streaming` (with `REINSTALL=1` for a model already set up). + Stopping: the engine releases its page-locked RAM (tens of GB) on SIGTERM, which takes longer than + Docker's default 10 s; give it time, or `docker stop` kills it (exit 137): + `docker run --stop-timeout 60 ...`, `docker stop -t 60 `, or `stop_grace_period: 60s` in Compose. ## Older CPUs (experimental)