File size: 6,076 Bytes
083e9dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env bash
# Stack 100% do Assistente on-prem na RTX PRO 6000 — paridade com o dataset.
# Gaps a fechar: embed(bge-m3) rerank(bge-v2-m3) stt(whisper-large-v3) vision(Qwen2.5-VL-7B)
#                Llama-3.3-70B + Prompt-Guard-86M + BF16 faltantes (14B, Coder-7B).
# 1 GPU, exclusivo, NGC vLLM. docker SEM sudo (scherm no grupo docker).
set -u
IMG="nvcr.io/nvidia/vllm:26.03.post1-py3"
TAG="NVIDIA_RTX_PRO_6000_Blackwell"
RID="stack$(cat /proc/sys/kernel/random/uuid | cut -c1-6)"
OUT=/work/results
HOSTRES=~/bench/results
HF=$(grep -oE 'hf_[A-Za-z0-9]+' ~/.scherm_hf_token 2>/dev/null | head -1)
PAGES=~/bench/pages           # imagens de teste (vision/ocr)
mkdir -p "$HOSTRES"

log(){ echo "[$(date +%H:%M:%S)] $*"; }
dk(){ docker "$@"; }

# mata QUALQUER container que esteja segurando a porta 8000 (não só pelo nome)
free_port(){
  local c; c=$(dk ps -q --filter "publish=8000")
  [ -n "$c" ] && { log "  liberando porta 8000 (container $c)"; dk rm -f $c >/dev/null 2>&1; sleep 3; }
}
# sobe um vLLM server e espera ficar pronto — VALIDANDO que serve o modelo CERTO
serve(){  # serve <cname> <model> <extra-vllm-args...>
  local cname=$1 model=$2; shift 2
  free_port; dk rm -f "$cname" >/dev/null 2>&1
  dk run -d --name "$cname" --gpus all --ipc=host \
     -v ~/.cache/huggingface:/root/.cache/huggingface \
     -v "$HOSTRES":/work/results -v "$PAGES":/pages \
     -v ~/bench/scripts:/scripts \
     -e HF_TOKEN="$HF" -e PYTHONUNBUFFERED=1 \
     -p 8000:8000 "$IMG" \
     vllm serve "$model" --served-model-name "$model" --port 8000 "$@" >/dev/null
  log "  aguardando $model subir..."
  for i in $(seq 1 120); do
    # PRONTO só se /v1/models listar EXATAMENTE este modelo (evita falso-200 de server antigo)
    if curl -sf -m3 http://localhost:8000/v1/models 2>/dev/null | grep -qF "\"$model\""; then
      log "  ✅ $model PRONTO (validado)"; return 0
    fi
    dk ps -q -f name="$cname" | grep -q . || { log "  ❌ container $cname morreu:"; dk logs --tail 30 "$cname"; return 1; }
    sleep 10
  done
  log "  ❌ timeout subindo $model"; dk logs --tail 20 "$cname"; return 1
}
kill_srv(){ dk rm -f "$1" >/dev/null 2>&1; sleep 4; }

###################### 1) EMBEDDING — bge-m3 ######################
log "########## embed bge-m3 ##########"
if serve emb BAAI/bge-m3 --runner pooling --max-model-len 8192 --gpu-memory-utilization 0.90 --trust-remote-code; then
  dk exec emb python3 /scripts/run_embed.py --served-model BAAI/bge-m3 --base-url http://localhost:8000 \
     --concurrencies 1 8 32 64 --batch-sizes 1 32 --reps 10 --out "$OUT" --tag "$TAG" --run-id "$RID" 2>&1
fi
kill_srv emb

###################### 2) RERANK — bge-reranker-v2-m3 ######################
log "########## rerank bge-reranker-v2-m3 ##########"
if serve rrk BAAI/bge-reranker-v2-m3 --runner pooling --max-model-len 8192 --gpu-memory-utilization 0.90 --trust-remote-code; then
  dk exec rrk python3 /scripts/run_rerank.py --served-model BAAI/bge-reranker-v2-m3 --base-url http://localhost:8000 \
     --concurrencies 1 8 32 64 --reps 10 --out "$OUT" --tag "$TAG" --run-id "$RID" 2>&1
fi
kill_srv rrk

###################### 3) VISION — Qwen2.5-VL-7B ######################
log "########## vision Qwen2.5-VL-7B ##########"
if serve vis Qwen/Qwen2.5-VL-7B-Instruct --max-model-len 8192 --gpu-memory-utilization 0.92 --trust-remote-code; then
  dk exec vis python3 /scripts/run_vision.py --served-model Qwen/Qwen2.5-VL-7B-Instruct --base-url http://localhost:8000 \
     --concurrencies 1 4 8 16 --reps 10 --max-tokens 512 --out "$OUT" --tag "$TAG" --run-id "$RID" 2>&1
fi
kill_srv vis

###################### 4) CHAT BF16 faltantes + Llama-3.3-70B + Prompt-Guard ######################
# serving padrão: run_serving.py contra vLLM /v1/chat
chat(){  # chat <cname> <model> <extra-args...>
  local cname=$1 model=$2; shift 2
  log "########## serving $model ##########"
  if serve "$cname" "$model" "$@"; then
    dk exec "$cname" python3 /scripts/run_serving.py --served-model "$model" --base-url http://localhost:8000/v1 \
       --concurrencies 1 4 8 16 32 64 128 --reps 5 --input-len 512 --output-len 128 \
       --out "$OUT" --tag "$TAG" --run-id "$RID" 2>&1
  fi
  kill_srv "$cname"
}
chat c14bf  Qwen/Qwen2.5-14B-Instruct       --max-model-len 8192 --gpu-memory-utilization 0.92
chat ccod7bf Qwen/Qwen2.5-Coder-7B-Instruct --max-model-len 8192 --gpu-memory-utilization 0.92
# Llama-3.3-70B: BF16 (~140GB) NÃO cabe em 96GB. Usar AWQ canônico (~40GB), igual o dataset (só tem 70B-AWQ).
chat c70 casperhansen/llama-3.3-70b-instruct-awq --max-model-len 8192 --gpu-memory-utilization 0.95 --quantization awq_marlin
# Prompt-Guard-86M: classifier (não-chat) — não serve em /v1/chat, não está no dataset. GAP aberto p/ TODAS as máquinas (runner próprio depois).

###################### 5) STT — whisper-large-v3 (faster-whisper, container python) ######################
# Não usa vLLM: faster-whisper (CTranslate2) direto. RTX é x86 Blackwell → compila (≠ L40S/Grace ARM).
log "########## stt whisper-large-v3 (faster-whisper) ##########"
dk rm -f stt >/dev/null 2>&1
free_port
dk run --rm --gpus all \
   -v ~/.cache/huggingface:/root/.cache/huggingface \
   -v "$HOSTRES":/work/results -v ~/bench/scripts:/scripts \
   -e HF_TOKEN="$HF" -e PYTHONUNBUFFERED=1 \
   "$IMG" bash -lc '
     # faster-whisper (CTranslate2) precisa do cublas/cudnn cu12 — NGC não expõe no LD path do CT2
     pip install -q faster-whisper soundfile numpy nvidia-cublas-cu12 nvidia-cudnn-cu12 2>&1 | tail -1
     PY=$(python3 -c "import nvidia.cublas.lib,nvidia.cudnn.lib,os;print(os.path.dirname(nvidia.cublas.lib.__file__)+\":\"+os.path.dirname(nvidia.cudnn.lib.__file__))")
     export LD_LIBRARY_PATH="$PY:${LD_LIBRARY_PATH:-}"
     python3 /scripts/run_stt.py --model large-v3 --device cuda --compute-type float16 \
       --durations 30 120 --concurrencies 1 4 --reps 10 --warmups 1 --language pt \
       --out /work/results --tag "'"$TAG"'" --run-id "'"$RID"'"
   ' 2>&1

log "########## STACK COMPLETA RTX — FIM ##########"
echo "STACK_RTX_COMPLETO"