xiaowei-system/scripts/llama-switch.sh

39 lines
1.8 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
# llama-server 模型切换开关minicpm ↔ off2026-09-08主力已由 Qwen3.5-4B 切 MiniCPM5-2B
# 用法: llama-switch.sh minicpm|4b|off|status
# 服务占用 :8080 端口
# 铁律来源: 3B 曾以 ctx 16384 CPU 推理致 RSS 7.6GB 内存黑洞; 7B/3B 均不再部署。4B 已由 MiniCPM5-2B 替换(省显存1.27G+快一倍)。
case "$1" in
3b|7b)
echo "🛑 3B/7B 已禁用(牧尘 2026-09-07 铁律)——本机只允许 MiniCPM5-2B (llama-server-4b unit)。"
echo " 原因: 3B CPU 推理 RSS 7.6GB 内存黑洞; MiniCPM5-2B GPU 部署仅需 VRAM 1.9G + host ~500MB。"
exit 1
;;
4b)
echo " 4B 已由 MiniCPM5-2B 替换2026-09-08——启动 MiniCPM同 unit llama-server-4b 跑 MiniCPM 权重)。"
systemctl --user start llama-server-4b
echo "✅ 已启动 MiniCPM5-2B (Q4_K_M, ctx 90112/88K, KV q8_0, reasoning off) @ :8080"
;;
minicpm|start)
systemctl --user start llama-server-4b
echo "✅ 已启动 MiniCPM5-2B (Q4_K_M, ctx 90112/88K, KV q8_0, reasoning off) @ :8080"
;;
off)
systemctl --user stop llama-server-4b 2>/dev/null
echo "🛑 本地 LLM 服务已停止"
;;
status)
_s4b=$(systemctl --user is-active llama-server-4b 2>/dev/null)
if [ "$_s4b" = "active" ]; then
echo "🟢 当前: MiniCPM5-2B (Q4_K_M, ctx 90112/88K, KV q8_0, reasoning off) @ :8080"
echo " 显存: $(nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits) MiB / 4096 MiB"
else
echo "⚪ 本地 LLM 服务未运行llama-server-4b inactive"
fi
;;
*)
echo "用法: llama-switch.sh minicpm|off|status 3B/7B 已禁用)"
;;
esac