m64_e51ffc16a885 / start.sh
33 lines, 1.2 KBraw
1#!/usr/bin/env bash2# z-image-gb10 entrypoint. Runs inside the container; takes no arguments.3# Port of gx10 ~/code/vlmtest/machines/gx10/start_z_image.sh: the same server4# (vlmtest/z_image_server.py, copied unchanged) with the same env, on pinned weights mounted5# read-only at /weights/zimage. 6set -eu78export HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=19export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True10export MODEL_DIR="/weights/zimage"11export SERVED_MODEL_ID="z-image-6b"12export PORT="$M64_PORT"1314echo '{"phase":"loading","detail":"loading Z-Image 6B (base)"}' >> "$M64_STATUS"15# The server loads its model before it listens (or answers /health with "loading"):16# report ready once /health says "ok".17python3 - <<'PY' &18import json, os, time, urllib.request19url = "http://127.0.0.1:%s/health" % os.environ["M64_PORT"]20opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))21while True:22 try:23 r = opener.open(url, timeout=3)24 if r.status == 200 and json.loads(r.read() or b"{}").get("status", "ok") == "ok":25 break26 except Exception:27 pass28 time.sleep(5)29with open(os.environ["M64_STATUS"], "a") as f:30 f.write(json.dumps({"phase": "ready"}) + "\n")31PY3233exec python3 -u /capsule/z_image_server.py