#!/usr/bin/env bash set -euo pipefail MODEL_ID="${MODEL_ID:-meta-llama/Llama-3.1-8B-Instruct}" mkdir -p /tmp/vllm # Docker Spaces expect the configured port to answer while the batch workers warm up. python3 -m http.server 7860 --bind 0.0.0.0 --directory /app & for GPU in 0 1 2 3; do PORT=$((8000 + GPU)) CUDA_VISIBLE_DEVICES="$GPU" vllm serve "$MODEL_ID" --host 127.0.0.1 --port "$PORT" \ --dtype auto --max-model-len 6144 --gpu-memory-utilization 0.92 \ --enable-prefix-caching --served-model-name compact-retracer >"/tmp/vllm/$GPU.log" 2>&1 & done python3 /app/wait_for_vllm.py python3 /app/generate.py # Keep the Space alive after a bounded run, so its logs and status stay available. wait