Spaces:
Paused
Paused
Download start.sh from viarl199020/BITNET: direct link, hf CLI and curl.
- Browser
- Download file 1.81 kB
-
https://huggingface.co/spaces/viarl199020/BITNET/resolve/main/start.sh
- Command line
-
hf download hf://spaces/viarl199020/BITNET/start.sh
-
curl -L -o start.sh https://huggingface.co/spaces/viarl199020/BITNET/resolve/main/start.sh
1.81 kB
| set -e | |
| N_CTX="${N_CTX:-4096}"; N_THREADS="${N_THREADS:-2}" | |
| LLAMA_PORT="${LLAMA_PORT:-8080}"; PORT="${PORT:-7860}"; WORKER_ID="${WORKER_ID:-A}" | |
| echo "[START] Omni-Nexus Worker ${WORKER_ID} (chat)" | |
| GGUF=$(find /models -name "*.gguf" -type f | head -1) | |
| [ -z "$GGUF" ] && { echo "[START] FATAL: sin .gguf"; ls -lah /models; exit 1; } | |
| echo "[START] Modelo: $(du -h "$GGUF" | cut -f1)" | |
| if ! llama-server --version >/dev/null 2>&1; then | |
| echo "[START] FATAL: llama-server no ejecuta. Librerías:" | |
| ldd "$(readlink -f "$(command -v llama-server)")" 2>&1 | grep -i "not found" || true | |
| exit 1 | |
| fi | |
| echo "[START] llama-server OK" | |
| LOG=/tmp/llama.log; : > "$LOG" | |
| # NOTA: se eliminaron --cache-type-k/--cache-type-v q8_0. | |
| # Cuantizar el caché V exige --flash-attn ("V cache quantization requires | |
| # flash_attn"), y flash-attn en CPU no aporta nada: está pensado para GPU. | |
| # Con ctx 4096 el caché sin cuantizar ocupa ~450 MB, que sobra de los 16 GB | |
| # del Space. No merece la pena complicarlo. | |
| llama-server --model "$GGUF" --host 127.0.0.1 --port "$LLAMA_PORT" \ | |
| --ctx-size "$N_CTX" --threads "$N_THREADS" --n-gpu-layers 0 \ | |
| --cont-batching --parallel 1 \ | |
| 2>&1 | tee "$LOG" | sed 's/^/[LLAMA] /' & | |
| PID=$!; MAX=300; T=0 | |
| while [ $T -lt $MAX ]; do | |
| kill -0 $PID 2>/dev/null || { | |
| echo "[START] murió. Causa probable:" | |
| grep -iE "error|failed|requires|cannot|unable" "$LOG" | tail -5 | |
| exit 1 | |
| } | |
| curl -sf "http://127.0.0.1:${LLAMA_PORT}/health" >/dev/null 2>&1 && { echo "[START] ONLINE en ${T}s"; break; } | |
| sleep 5; T=$((T+5)); [ $((T % 30)) -eq 0 ] && echo "[START] ${T}/${MAX}s..." | |
| done | |
| [ $T -ge $MAX ] && { echo "[START] FATAL: timeout"; tail -20 "$LOG"; exit 1; } | |
| exec uvicorn server:app --host 0.0.0.0 --port "$PORT" --workers 1 --log-level info | |