xiaowei-system/scripts/llama-switch.sh

34 lines
1.3 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
# llama-server 模型切换开关4b ↔ off2026-09-07 牧尘铁律3B/7B 禁止使用,已从开关移除)
# 用法: llama-switch.sh 4b|off|status
# 服务占用 :8080 端口
# 铁律来源: 3B 曾以 ctx 16384 CPU 推理致 RSS 7.6GB 内存黑洞; 7B/3B 均不再部署。
case "$1" in
3b|7b)
echo "🛑 3B/7B 已禁用(牧尘 2026-09-07 铁律)——本机只允许 4B (llama-server-4b)。"
echo " 原因: 3B CPU 推理 RSS 7.6GB 内存黑洞; 4B GPU 部署仅需 VRAM 3.1G + host ~480MB。"
exit 1
;;
4b)
systemctl --user start llama-server-4b
echo "✅ 已启动 4B (Qwen3.5-4B Q4_K_M, 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 "🟢 当前: 4B (Qwen3.5-4B Q4_K_M, 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 4b|off|status 3B/7B 已禁用)"
;;
esac