Files
worker-vllm/start.sh
T
2025-10-28 14:39:55 -04:00

29 lines
695 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# /usr/local/bin/start.sh
#!/usr/bin/env bash
set -euo pipefail
# If user didn’t set it explicitly, infer from visible GPUs.
if [[ -z "${TENSOR_PARALLEL_SIZE:-}" ]]; then
if command -v nvidia-smi >/dev/null 2>&1; then
COUNT="$(nvidia-smi -L | wc -l | tr -d ' ')"
else
# Fallback to PyTorch if available
COUNT="$(python3 - <<'PY'
try:
import torch
print(torch.cuda.device_count() or 0)
except Exception:
print(0)
PY
)"
fi
# Respect CUDA_VISIBLE_DEVICES (both methods above do, since they see only visible GPUs).
if [[ "${COUNT}" -lt 1 ]]; then
COUNT=1
fi
export TENSOR_PARALLEL_SIZE="${COUNT}"
fi
echo "TENSOR_PARALLEL_SIZE=${TENSOR_PARALLEL_SIZE}"