m64_9550b2f59469 / start.sh
32 lines, 1.4 KBraw
1#!/usr/bin/env bash2# bonsai-image-4b-gb10 entrypoint. Runs inside the container; takes no arguments.3# Port of gx10 ~/code/vlmtest/machines/gx10/start_bonsai.sh: the same server4# (vlmtest/bonsai_server.py, copied unchanged) with the same env, on pinned weights mounted5# read-only at /weights/bonsai. gx10 ran it on vllm/vllm-openai with diffusers from main; Flux2KleinPipeline needs a newer diffusers than the vllm-based capsules pin, so this uses the flux2-klein-4b-gb10 base.6set -eu78export HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=19export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True10export BONSAI_MODEL_DIR="/weights/bonsai"11export PORT="$M64_PORT"1213echo '{"phase":"loading","detail":"loading Bonsai Image 4B (ternary FLUX.2 klein)"}' >> "$M64_STATUS"14# The server loads its model before it listens (or answers /health with "loading"):15# report ready once /health says "ok".16python3 - <<'PY' &17import json, os, time, urllib.request18url = "http://127.0.0.1:%s/health" % os.environ["M64_PORT"]19opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))20while True:21 try:22 r = opener.open(url, timeout=3)23 if r.status == 200 and json.loads(r.read() or b"{}").get("status", "ok") == "ok":24 break25 except Exception:26 pass27 time.sleep(5)28with open(os.environ["M64_STATUS"], "a") as f:29 f.write(json.dumps({"phase": "ready"}) + "\n")30PY3132exec python3 -u /capsule/bonsai_server.py