This commit is contained in:
2026-08-12 12:17:36 +08:00
parent b8662138a9
commit 15830ff0df
10 changed files with 90 additions and 17 deletions
+30
View File
@@ -0,0 +1,30 @@
#!/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"