xiaowei-system/scripts/llama-switch.sh

39 lines
1.4 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 模型切换开关3b ↔ 7b ↔ off
# 用法: llama-switch.sh 3b|7b|off|status
# 两个服务共用 :8080 端口,同一时刻只能有一个运行
case "$1" in
3b)
systemctl --user stop llama-server-7b 2>/dev/null
systemctl --user start llama-server
echo "✅ 已切换到 3B (Qwen2.5-3B Q4_K_M)"
;;
7b)
systemctl --user stop llama-server
systemctl --user start llama-server-7b
echo "✅ 已切换到 7B (Qwen2.5-7B Q3_K_M)"
;;
off)
systemctl --user stop llama-server
systemctl --user stop llama-server-7b
echo "🛑 本地 LLM 服务已停止"
;;
status)
_s3b=$(systemctl --user is-active llama-server 2>/dev/null)
_s7b=$(systemctl --user is-active llama-server-7b 2>/dev/null)
if [ "$_s3b" = "active" ]; then
echo "🟢 当前: 3B (Qwen2.5-3B Q4_K_M) @ :8080"
echo " 显存: $(nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits) MiB"
elif [ "$_s7b" = "active" ]; then
echo "🟢 当前: 7B (Qwen2.5-7B Q3_K_M) @ :8080"
echo " 显存: $(nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits) MiB"
else
echo "⚪ 本地 LLM 服务未运行"
fi
;;
*)
echo "用法: llama-switch.sh 3b|7b|off|status"
;;
esac