Files
rag-local/scripts/start_models.sh
T
2026-08-12 12:17:36 +08:00

31 lines
1.1 KiB
Bash
Executable File
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.
#!/bin/bash
# 启动本地 MLX 模型服务:chat + embedding 均由 oMLX(18080) 提供
# chat=Qwen3.5-9B-MLX-4bit4-bit),embedding=BGE-M3oMLX 原生 BERT 系支持)
# 用法: ./scripts/start_models.sh
set -u
cd "$(dirname "$0")/.."
ROOT=$(pwd)
VENV="$ROOT/.venv"
LOG_DIR="$HOME/.omlx/logs"
CACHE_DIR="$HOME/.omlx/cache"
mkdir -p "$LOG_DIR" "$CACHE_DIR"
# oMLX 模型目录:chatQwen3.5-9B-MLX-4bit+ embeddingbge-m3)均为实体目录,oMLX 按目录扫描注册模型
OMLX_MODEL_DIR="$ROOT/models/mlx/omlx"
if lsof -iTCP:18080 -sTCP:LISTEN >/dev/null 2>&1; then
echo "[skip] oMLX 18080 已被占用"
else
# 内存策略写在 ~/.omlx/settings.jsoncustom 上限 14GB),
# CLI 不加 --memory-guard,避免覆盖 settings.json 的 custom 配置
nohup "$VENV/bin/omlx" serve \
--model-dir "$OMLX_MODEL_DIR" \
--host 127.0.0.1 --port 18080 \
--paged-ssd-cache-dir "$CACHE_DIR/omlx-cache" \
--max-concurrent-requests 8 \
--log-level info >> "$LOG_DIR/mlx-chat.log" 2>&1 &
echo "[start] oMLX chat+embedding -> 127.0.0.1:18080 (pid $!)"
fi
echo "日志: $LOG_DIR/mlx-chat.log"