Files

59 lines
1.6 KiB
Bash
Raw Permalink 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/bin/env bash
#
# 一键构建 + 启动 Llama 4 Scout(8 卡)
#
# MODEL_HOST_DIR=/mnt/disk0/models/LLM-Research/Llama-4-Scout-17B-16E-Instruct \
# ./run.sh
#
set -euo pipefail
IMAGE="${IMAGE:-llama4-scout:2026-10-23}"
NAME="${NAME:-llama4-scout}"
PORT="${PORT:-8091}"
MODEL_HOST_DIR="${MODEL_HOST_DIR:-/mnt/disk0/models/LLM-Research/Llama-4-Scout-17B-16E-Instruct}"
if [[ ! -f "${MODEL_HOST_DIR}/config.json" ]]; then
echo "ERROR: 模型目录不完整: ${MODEL_HOST_DIR}/config.json" >&2
echo "请先下载模型,或设置 MODEL_HOST_DIR 指向正确目录。" >&2
exit 1
fi
echo "==> build ${IMAGE}"
docker build -t "${IMAGE}" .
echo "==> recreate ${NAME}"
docker rm -f "${NAME}" 2>/dev/null || true
# Iluvatar 运行时需要 privileged + /dev 绑定。
# 只给 --device=/dev/iluvatar* 会在 worker init 时报
# cudaGetDeviceCount() ... Error 1001
# 这是厂商驱动/容器运行时要求,不是 vLLM 本身的要求。
docker run -d --name "${NAME}" \
--privileged \
--pid host \
--network host \
--ipc host \
-v /dev:/dev \
-v "${MODEL_HOST_DIR}:/models/llama4-scout:ro" \
--ulimit memlock=-1 \
--ulimit stack=67108864 \
-e TP=8 \
-e MAX_MODEL_LEN=4096 \
-e MAX_NUM_SEQS=1 \
-e GPU_MEM_UTIL=0.90 \
--restart unless-stopped \
"${IMAGE}"
echo "==> wait for http://127.0.0.1:${PORT}/health"
for _ in $(seq 1 120); do
if curl -sf "http://127.0.0.1:${PORT}/health" >/dev/null 2>&1; then
echo "ready: http://127.0.0.1:${PORT}/v1/models"
exit 0
fi
sleep 5
done
echo "ERROR: 服务 10 分钟未就绪,查看日志:" >&2
echo " docker logs -f ${NAME}" >&2
exit 1