本地LLM相關~[05]在ARM的LINUX(ACER GB10 這台設備)上完成AI大模型伺服器的架設
本地LLM相關~[05]在ARM的LINUX(ACER GB10 這台設備)上完成AI大模型伺服器的架設
包含了
1. Redis 服務:用於高速分散式流控 (Rate Limiting) 與快取 [port: 6379:6379]
2. PostgreSQL 資料庫:儲存 LiteLLM 的金鑰、額度、用戶與消費日誌 [port: 5432:5432]
3. vLLM 服務(已修正位置參數與 Tool Call Parser)(載入 Qwen3.6-35B-A3B-NVFP4) [port: 8000:8000]
4. LiteLLM Proxy 閘道:嚴格等待 vLLM 載入完畢後才對外服務 [port: 4000:4000]
5. Open WebUI (私有化ChatGPT) [port: 3000:8080]
6. SearXNG:在地端運作的隱私搜尋引擎(擴充Open WebUI網路搜尋功能)
相關設定檔01.docker-compose.yml [完整路徑: /data]
services:
# ----------------------------------------------------------------
# 1. Redis 服務:用於高速分散式流控 (Rate Limiting) 與快取
# ----------------------------------------------------------------
redis:
image: redis:7-alpine
container_name: litellm-redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- ./redis_data:/data
# ----------------------------------------------------------------
# 2. PostgreSQL 資料庫:儲存 LiteLLM 的金鑰、額度、用戶與消費日誌
# ----------------------------------------------------------------
db:
image: postgres:16-alpine
container_name: litellm-db
restart: unless-stopped
environment:
POSTGRES_USER: litellm_user
POSTGRES_PASSWORD: SecurePassword123! # 💡 生產環境建議修改此密碼
POSTGRES_DB: litellm_db
volumes:
- ./postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
# ----------------------------------------------------------------
# 3. vLLM 服務(已修正位置參數與 Tool Call Parser)
# ----------------------------------------------------------------
vllm-qwen:
image: vllm/vllm-openai:latest-aarch64
container_name: vllm-qwen
restart: unless-stopped
ipc: host
ports:
- "8000:8000"
volumes:
- /data/models/Qwen/Qwen3.6-35B-A3B-NVFP4:/model
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
environment:
- FORCE_CUDA=1
- PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
- VLLM_TORCH_COMPILE_LEVEL=0
# 🎯 修正處:直接把 /model 當作位置參數置於最前,並改用 qwen3_xml 解析器
command: >
/model
--served-model-name Qwen3.6-35B-FP4
--api-key "MySecretKey_123456"
--gpu-memory-utilization 0.70
--max-model-len 65536
--trust-remote-code
--quantization modelopt
--max-num-seqs 64
--max-num-batched-tokens 2048
--kv-cache-dtype fp8
--enforce-eager
--enable-auto-tool-choice
--tool-call-parser qwen3_xml
healthcheck:
test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
interval: 10s
timeout: 5s
retries: 60
start_period: 90s
# ----------------------------------------------------------------
# 4. LiteLLM Proxy 閘道:嚴格等待 vLLM 載入完畢後才對外服務
# ----------------------------------------------------------------
litellm-proxy:
image: ghcr.io/berriai/litellm:main-v1.60.0
container_name: litellm-proxy
restart: unless-stopped
ports:
- "4000:4000"
volumes:
- ./litellm-config.yaml:/app/config.yaml
depends_on:
db:
condition: service_started
redis:
condition: service_started
vllm-qwen:
condition: service_healthy
environment:
- DATABASE_URL=postgresql://litellm_user:SecurePassword123!@db:5432/litellm_db
- REDIS_URL=redis://litellm-redis:6379
- LITELLM_MASTER_KEY=sk-master-key-1234567890
command: [ "--config", "/app/config.yaml" ]
# ----------------------------------------------------------------
# 5. Open WebUI (已啟用帳號密碼登入與註冊)
# ----------------------------------------------------------------
open-webui:
image: ghcr.io/open-webui/open-webui:main
container_name: open-webui
restart: unless-stopped
ports:
- "3000:8080"
volumes:
- ./webui_data:/app/backend/data
depends_on:
litellm-proxy:
condition: service_started
searxng: # 讓 WebUI 等待搜尋引擎啟動
condition: service_started
environment:
- OPENAI_API_BASE_URL=http://litellm-proxy:4000/v1
- OPENAI_API_KEY=sk-master-key-1234567890
- ENABLE_OLLAMA_API=False
# 🎯 【修改處:啟用登入驗證與註冊功能】
- WEBUI_AUTH=True # 開啟登入驗證
- ENABLE_SIGNUP=True # 開啟註冊功能(第一個註冊的帳號會自動變成管理員)
- WEBUI_NAME=Local AI Workspace
- ENABLE_RAG_WEB_SEARCH=True
- RAG_WEB_SEARCH_ENGINE=searxng
- RAG_WEB_SEARCH_RESULT_COUNT=3
- SEARXNG_QUERY_URL=http://searxng:8080/search?q=<query>
# ----------------------------------------------------------------
# 6. SearXNG:在地端運作的隱私搜尋引擎
# ----------------------------------------------------------------
searxng:
image: searxng/searxng:latest
container_name: searxng
restart: unless-stopped
# 🎯 新增 volumes 掛載本地設定檔
volumes:
- ./searxng:/etc/searxng
environment:
- SEARXNG_SETTINGS_URL=/etc/searxng/settings.yml
相關設定檔02.litellm-config.yaml [完整路徑: /data]
model_list:
- model_name: Qwen3.6-35B-FP4 # 👈 這是對外暴露給 API 呼叫的名字
litellm_params:
model: openai/Qwen3.6-35B-FP4 # 👈 必須是 openai/ 前綴加上 vLLM 宣告的模型名
api_base: http://vllm-qwen:8000/v1 # 👈 必須指向 Docker 內部的服務名稱
api_key: "MySecretKey_123456" # 👈 必須與 docker-compose.yml 裡的 --api-key 一致
相關設定檔03.settings.yml [完整路徑: /data/searxng/settings.yml]
# ./searxng/settings.yml
use_default_settings: true
server:
# 監聽所有介面以利容器間通訊
bind_address: "0.0.0.0"
port: 8080
secret_key: "secure_random_string_here" # 請隨意輸入一段隨機字串
search:
safe_search: 0
autocomplete: ""
# 🎯 關鍵:必須啟用 json 格式
formats:
- html
- json
安裝設定全過程紀錄檔
PW:Altosgb10f1
sudo apt update
sudo apt upgrade -y
#UBUNTU 安裝中文輸入法 [Ubuntu 安裝中文輸入法 Fcitx5] ~ https://share.gemini.google/jphfbxWLp0lo
sudo apt update
sudo apt install -y fcitx5 fcitx5-configtool fcitx5-chinese-addons fcitx5-chewing fcitx5-frontend-all
im-config -n fcitx5
重開機
#安裝完整 Python3 環境
sudo apt install -y \
python3 \
python3-dev \
python3-pip \
python3-venv \
python3-setuptools \
python3-wheel \
python3-full
#安裝常用開發工具
sudo apt install -y \
build-essential \
cmake \
git \
curl \
wget \
unzip \
zip \
pkg-config
#SSL 與憑證
sudo apt install -y \
ca-certificates \
openssl
#壓縮工具
sudo apt install -y \
pigz \
xz-utils \
p7zip-full
#系統監控
sudo apt install -y \
htop \
iotop \
nvtop \
tree \
jq
#安裝大語言模型下載器
python3 -m venv .venv
source .venv/bin/activate
pip install huggingface_hub #核心
hf --version
deactivate #離開語法
#建立大模型專屬資料夾
sudo mkdir -p /data/models
sudo chown altos:users /data/models
sudo chown $USER:$USER /data/models #$USER:$USER [擁有者和群組 ; groups可以查詢帳號本身所在群組]
#下載大模型
source .venv/bin/activate
hf download Qwen/Qwen3.6-35B-A3B \
--local-dir /data/models/Qwen/Qwen3.6-35B-A3B
hf download Qwen/Qwen3.6-35B-A3B-FP8 \
--local-dir /data/models/Qwen/Qwen3.6-35B-A3B-FP8
hf download nvidia/Qwen3.6-35B-A3B-NVFP4 \
--local-dir /data/models/Qwen/Qwen3.6-35B-A3B-NVFP4
deactivate #離開語法
==============
我要用下列 硬體規格
●主機主要規格
.品牌:Acer Altos
.型號:Altos BrainSphere™ GB10 F1工作站
.主機板晶片組:-
.處理器:Arm 20 核心(10× Cortex-X925 + 10× Cortex-A725)
.CUDA☆ Cores:6144
.Tensor Core:第五代
.RT Core:第四代
.Tensor 效能:1 PetaFLOP AI 運算效能*
*使用稀疏性( sparsity )功能時的理論峰值效能為 4 PFLOPS。
.記憶體容量:128GB LPDDR5x 統一系統記憶體
.固態硬碟:4TB NVMe M.2 具有自加密功能
.圖形處理器(GPU):NVIDIA Grace Blackwell
.作業系統:NVIDIA DGX™ OS
.主機型態:工作站/迷你電腦
我要如何安裝DOCKER建立日後好維護的vLLM環境 把完整流程和指令整理出來
https://grok.com/share/bGVnYWN5LWNvcHk_5f80d261-56fd-46c9-a345-d908cd880081
https://www.perplexity.ai/search/c94ce41e-5f29-41f0-be5c-37928954f3ff
https://share.gemini.google/NCgB58WDdTlx
https://chatgpt.com/share/6a51fdd9-9d98-83e8-bfb5-a28195ad85b8
#先更新系統:
sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y
#確認版本
uname -a
Linux gn100-d4d6 6.17.0-1026-nvidia #26-Ubuntu SMP PREEMPT_DYNAMIC Thu Jun 25 00:57:17 UTC 2026 aarch64 aarch64 aarch64 GNU/Linux
cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.4 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
#確認 GPU
nvidia-smi
Tue Jul 14 08:57:24 2026
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 580.159.03 Driver Version: 580.159.03 CUDA Version: 13.0 |
+-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GB10 On | 0000000F:01:00.0 On | N/A |
| N/A 38C P0 5W / N/A | Not Supported | 2% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| 0 N/A N/A 34457 G /usr/lib/xorg/Xorg 117MiB |
| 0 N/A N/A 34653 G /usr/bin/gnome-shell 176MiB |
| 0 N/A N/A 35337 G /usr/bin/gnome-text-editor 39MiB |
| 0 N/A N/A 40407 G .../8593/usr/lib/firefox/firefox 223MiB |
+-----------------------------------------------------------------------------------------+
#安裝 Docker
curl -fsSL https://get.docker.com | sudo sh #判斷是否以安裝 docker --version
#加入Docker權限
sudo usermod -aG docker altos #sudo usermod -aG docker $USER
# 啟用 Docker 服務開機自啟
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
#Altos aiGeni安裝說明 [Altos-aiGeni_Installation-Guide_ZH_1_01_0010-arm64.pdf]
cd /home/altos/Desktop/Altos_aigeni_installer_1.01.0010-arm64.run
bash altos_aigeni_installer_1.01.0010-arm64.run
#安裝 NVIDIA Container Toolkit [ nvidia-ctk --version #檢查是否以安裝]
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey \
| sudo gpg --dearmor \
-o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg #加入套件來源
curl -s -L \
https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list \
| sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' \
| sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list #加入套件來源
sudo apt update
sudo apt install -y nvidia-container-toolkit
#設定 Docker 和 NVIDIA Container Toolkit 綁定
sudo nvidia-ctk runtime configure --runtime=docker
重開機
#安裝 Docker Compose ~ Docker 官方提供的一個工具,用於定義和執行多容器的 Docker 應用程式。只需透過一個名為 compose.yaml 的 YAML 設定檔,即可集中配置所有應用程式所需的服務、網路與資料卷,並使用單一指令同時啟動或停止所有容器。
docker compose version #確定是否以安裝
Docker Compose version v5.0.2
#安裝 Docker Compose ~ sudo apt install docker-compose-plugin
#建立Docker專屬資料夾 [/opt/ai-stack -> /data]
#sudo mkdir -p /data/models
#sudo chown altos:users /data/models
sudo chown altos:users /data/models/Qwen
sudo chown altos:users /data
sudo mkdir -p /data/{cache,logs,config,scripts}
sudo chown altos:users /data/cache
sudo chown altos:users /data/logs
sudo chown altos:users /data/config
sudo chown altos:users /data/scripts
sudo mkdir -p /data/cache/{huggingface,pip}
sudo chown altos:users /data/cache/huggingface
sudo chown altos:users /data/cache/pip
sudo mkdir -p /data/logs/vllm
sudo chown altos:users /data/logs/vllm
#建立 docker-compose.yml
nano /data/docker-compose.yml #nano /opt/ai-stack/docker-compose.yml
services:
vllm-qwen:
image: vllm/vllm-openai:latest-aarch64 # 保留您原本完美運作的 ARM 專用映像檔
container_name: vllm-qwen
restart: unless-stopped
ipc: host
ports:
- "8000:8000"
volumes:
# ⚠️ 請確保左邊的「主機路徑」對應您下載 NVFP4 模型的實際路徑
- /data/models/Qwen/Qwen3.6-35B-A3B-NVFP4:/model
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
environment:
- FORCE_CUDA=1
- PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
# ⚠️ 徹底關閉 PyTorch 慢速編譯(維持您的完美設定)
- VLLM_TORCH_COMPILE_LEVEL=0
command: >
--model /model
--served-model-name Qwen3.6-35B-FP4
--api-key "MySecretKey_123456"
--gpu-memory-utilization 0.70
--max-model-len 65536
--trust-remote-code
--quantization modelopt
--max-num-seqs 64
--max-num-batched-tokens 2048
--kv-cache-dtype fp8
--enforce-eager
# 在與 docker-compose.yml 相同的目錄下建立 .env
nano .env
# =========================================================================
# vLLM 基礎路徑設定
# =========================================================================
# Hugging Face 快取目錄路徑(若有需要從線上拉取權重時會用到)
HF_HOME=/data/cache/huggingface
# 主機上存放模型的主目錄路徑
MODEL_DIR=/data/models
# 日誌輸出目錄
LOG_DIR=/data/logs
# =========================================================================
# 模型指定(指向容器內部的對應路徑)
# =========================================================================
# 說明:
# 主機的 /data/models/Qwen/Qwen3.6-35B-A3B
# 對應到容器內就是 /models/Qwen/Qwen3.6-35B-A3B
MODEL_NAME=/models/Qwen/Qwen3.6-35B-A3B
#釋放系統 Cache 記憶體(最快、最推薦)
sudo sync && sudo sysctl -w vm.drop_caches=3
free -h
#擴大置換空間(Swap
# 關閉舊的 swap
sudo swapoff -a
# 建立一個 64GB 的 swap 空間
sudo dd if=/dev/zero of=/swapfile bs=1G count=64
sudo chmod 600 /swapfile
sudo mkswap /swapfile
# 啟用新的 swap
sudo swapon /swapfile
#啟動 vLLM
cd /data
docker compose up -d #啟動
docker logs -f vllm-qwen #查看日誌
#INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
#只有當你看到日誌出現以下這一行,才代表成功,這時才能開另一個終端機去跑 curl 測試:
docker compose down #停止
#CURL測試
curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer MySecretKey_123456" -d '{
"model": "Qwen3.6-35B",
"messages": [
{"role": "user", "content": "你好!請用繁體中文自我介紹,並說說你對 這台搭 載 NVIDIA Grace Blackwell 晶片的工作站有何看法?"}
],
"temperature": 0.7
}'
{"error":{"message":"The model `Qwen3.6-35B` does not exist.","type":"NotFoundError","param":"model","code":404}}
~~~~~~~~~~~~~~~~~
curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer MySecretKey_123456" -d '{
"model": "Qwen3.6-35B-FP4",
"messages": [
{"role": "user", "content": "你好!請用繁體中文自我介紹"}
],
"temperature": 0.7
}'
curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer MySecretKey_123456" -d '{
"model": "Qwen3.6-35B-FP4",
"messages": [
{"role": "user", "content": "這台搭 載 處理器:Arm 20 核心(10× Cortex-X925 + 10× Cortex-A725)晶片的工作站建置vLLM提供給hermes agent有何看法?"}
],
"temperature": 0.7
}'
#限制回覆字數為150字避免長篇大論等太久
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer MySecretKey_123456" \
-d '{
"model": "Qwen3.6-35B-FP4",
"messages": [
{"role": "user", "content": "這台搭載處理器:Arm 20 核心(10× Cortex-X925 + 10× Cortex-A725)晶片的工作站建置vLLM提供給hermes agent有何看法?"}
],
"temperature": 0.7,
"max_tokens": 150
}'
#使用curl+python3 實現能像 ChatGPT 網頁那樣平滑地、一字字吐出乾淨的中文,你可以配合 python 或 jq 工具來過濾。
curl -s -N http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer MySecretKey_123456" \
-d '{
"model": "Qwen3.6-35B-FP4",
"messages": [
{"role": "system", "content": "你是一位精通 AI 硬體與 Agent 架構的資深架構師。請一律使用「繁體中文(台灣)」為使用者解答,並保持專業與親切。"},
{"role": "user", "content": "這台搭載處理器:Arm 20 核心(10× Cortex-X925 + 10× Cortex-A725)晶片的工作站建置vLLM提供給hermes agent有何看法?"}
],
"temperature": 0.7,
"stream": true
}' | python3 -c "
import sys, json
for line in sys.stdin:
line = line.strip()
if line.startswith('data: '):
data_str = line[6:]
if data_str == '[DONE]':
break
try:
data = json.loads(data_str)
content = data['choices'][0]['delta'].get('content', '')litellm-config.yaml
print(content, end='', flush=True)
except Exception:
pass
"
================
LiteLLM Proxy 來實作 處理金鑰管理、使用者額度控制(Budget)、流控(Rate Limiting)以及呼叫統計 可商用的系統
001.停用docker
docker compose down #停止
002_01.編輯 LiteLLM 的設定檔 litellm-config.yaml [ 跟 docker-compose.yml 在相同目錄 ]
model_list:
- model_name: Qwen3.6-35B-FP4 # 👈 這是對外暴露給 API 呼叫的名字
litellm_params:
model: openai/Qwen3.6-35B-FP4 # 👈 必須是 openai/ 前綴加上 vLLM 宣告的模型名
api_base: http://vllm-qwen:8000/v1 # 👈 必須指向 Docker 內部的服務名稱
api_key: "MySecretKey_123456" # 👈 必須與 docker-compose.yml 裡的 --api-key 一致
002_02.編輯 searxng 的設定檔 [/data/searxng/settings.yml 就是docker-compose.yml的下面一層]
shell:
#cd /data
#mkdir -p ./searxng
#touch ./searxng/settings.yml
# ./searxng/settings.yml
use_default_settings: true
server:
# 監聽所有介面以利容器間通訊
bind_address: "0.0.0.0"
port: 8080
secret_key: "secure_random_string_here" # 請隨意輸入一段隨機字串
search:
safe_search: 0
autocomplete: ""
# 🎯 關鍵:必須啟用 json 格式
formats:
- html
- json
003.修改 docker-compose.yml 一次開啟四個docker
services:
# ----------------------------------------------------------------
# 1. Redis 服務:用於高速分散式流控 (Rate Limiting) 與快取
# ----------------------------------------------------------------
redis:
image: redis:7-alpine
container_name: litellm-redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- ./redis_data:/data
# ----------------------------------------------------------------
# 2. PostgreSQL 資料庫:儲存 LiteLLM 的金鑰、額度、用戶與消費日誌
# ----------------------------------------------------------------
db:
image: postgres:16-alpine
container_name: litellm-db
restart: unless-stopped
environment:
POSTGRES_USER: litellm_user
POSTGRES_PASSWORD: SecurePassword123! # 💡 生產環境建議修改此密碼
POSTGRES_DB: litellm_db
volumes:
- ./postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
# ----------------------------------------------------------------
# 3. vLLM 服務(已修正位置參數與 Tool Call Parser)
# ----------------------------------------------------------------
vllm-qwen:
image: vllm/vllm-openai:latest-aarch64
container_name: vllm-qwen
restart: unless-stopped
ipc: host
ports:
- "8000:8000"
volumes:
- /data/models/Qwen/Qwen3.6-35B-A3B-NVFP4:/model
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
environment:
- FORCE_CUDA=1
- PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
- VLLM_TORCH_COMPILE_LEVEL=0
# 🎯 修正處:直接把 /model 當作位置參數置於最前,並改用 qwen3_xml 解析器
command: >
/model
--served-model-name Qwen3.6-35B-FP4
--api-key "MySecretKey_123456"
--gpu-memory-utilization 0.70
--max-model-len 65536
--trust-remote-code
--quantization modelopt
--max-num-seqs 64
--max-num-batched-tokens 2048
--kv-cache-dtype fp8
--enforce-eager
--enable-auto-tool-choice
--tool-call-parser qwen3_xml
healthcheck:
test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
interval: 10s
timeout: 5s
retries: 60
start_period: 90s
# ----------------------------------------------------------------
# 4. LiteLLM Proxy 閘道:嚴格等待 vLLM 載入完畢後才對外服務
# ----------------------------------------------------------------
litellm-proxy:
image: ghcr.io/berriai/litellm:main-v1.60.0
container_name: litellm-proxy
restart: unless-stopped
ports:
- "4000:4000"
volumes:
- ./litellm-config.yaml:/app/config.yaml
depends_on:
db:
condition: service_started
redis:
condition: service_started
vllm-qwen:
condition: service_healthy
environment:
- DATABASE_URL=postgresql://litellm_user:SecurePassword123!@db:5432/litellm_db
- REDIS_URL=redis://litellm-redis:6379
- LITELLM_MASTER_KEY=sk-master-key-1234567890
command: [ "--config", "/app/config.yaml" ]
# ----------------------------------------------------------------
# 5. Open WebUI (已啟用帳號密碼登入與註冊)
# ----------------------------------------------------------------
open-webui:
image: ghcr.io/open-webui/open-webui:main
container_name: open-webui
restart: unless-stopped
ports:
- "3000:8080"
volumes:
- ./webui_data:/app/backend/data
depends_on:
litellm-proxy:
condition: service_started
searxng: # 讓 WebUI 等待搜尋引擎啟動
condition: service_started
environment:
- OPENAI_API_BASE_URL=http://litellm-proxy:4000/v1
- OPENAI_API_KEY=sk-master-key-1234567890
- ENABLE_OLLAMA_API=False
# 🎯 【修改處:啟用登入驗證與註冊功能】
- WEBUI_AUTH=True # 開啟登入驗證
- ENABLE_SIGNUP=True # 開啟註冊功能(第一個註冊的帳號會自動變成管理員)
- WEBUI_NAME=Local AI Workspace
- ENABLE_RAG_WEB_SEARCH=True
- RAG_WEB_SEARCH_ENGINE=searxng
- RAG_WEB_SEARCH_RESULT_COUNT=3
- SEARXNG_QUERY_URL=http://searxng:8080/search?q=<query>
# ----------------------------------------------------------------
# 6. SearXNG:在地端運作的隱私搜尋引擎
# ----------------------------------------------------------------
searxng:
image: searxng/searxng:latest
container_name: searxng
restart: unless-stopped
# 🎯 新增 volumes 掛載本地設定檔
volumes:
- ./searxng:/etc/searxng
environment:
- SEARXNG_SETTINGS_URL=/etc/searxng/settings.yml
004.一鍵啟動 4個 docker
cd /data
docker compose up -d
docker compose logs -f
docker logs -f vllm-qwen
docker compose ps #你應該會看到 litellm-db、vllm-qwen 和 litellm-proxy 三個容器的狀態都是 Up (running)
005.登入 LiteLLM Admin UI
http://127.0.0.1:4000/ui #http://<你的伺服器IP>:4000/
# LiteLLM Admin UI 的管理員金鑰 master_key: sk-master-key-1234567890
006.CURL測試
#vLLM 測試
curl http://localhost:8000/v1/chat/completions \# ./searxng/settings.yml
use_default_settings: true
server:
# 監聽所有介面以利容器間通訊
bind_address: "0.0.0.0"
port: 8080
secret_key: "secure_random_string_here" # 請隨意輸入一段隨機字串
search:
safe_search: 0
autocomplete: ""
# 🎯 關鍵:必須啟用 json 格式
formats:
- html
- json
-H "Content-Type: application/json" \
-H "Authorization: Bearer MySecretKey_123456" \
-d '{
"model": "Qwen3.6-35B-FP4",
"messages": [
{"role": "user", "content": "你好!"}
],
"max_tokens": 10
}'
007.LiteLLM Proxy 操作界面教學
https://ithelp.ithome.com.tw/articles/10391130
建立一組心api key: jash_TEST : sk-_nhcyv5DBD7L1pTY_-1ykg
#LiteLLM 轉發測試 ~單行版
curl -X POST http://localhost:4000/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer sk-master-key-1234567890" -d '{"model": "Qwen3.6-35B-FP4", "messages": [{"role": "user", "content": "你好!請用一句話介紹你自己。"}], "temperature": 0.7, "max_tokens": 100}'
#LiteLLM 轉發測試 ~多行板 [系統key]
curl -X POST http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-master-key-1234567890" \
-d '{"model": "Qwen3.6-35B-FP4", "messages": [{"role": "user", "content": "你好!請用一句話介紹你自己。"}], "temperature": 0.7, "max_tokens": 100}'
#LiteLLM 轉發測試 ~多行板 [jash_TEST key]
curl -X POST http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-_nhcyv5DBD7L1pTY_-1ykg" \
-d '{"model": "Qwen3.6-35B-FP4", "messages": [{"role": "user", "content": "你好!請用一句話介紹你自己。"}], "temperature": 0.7, "max_tokens": 100}'
#LiteLLM 轉發測試 ~chatgpt mode[系統key]
curl -s -N http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-master-key-1234567890" \
-d '{
"model": "Qwen3.6-35B-FP4",
"messages": [
{"role": "system", "content": "你是一位精通 AI 硬體與 Agent 架構的資深架構師。請一律使用「繁體中文(台灣)」為使用者解答,並保持專業與親切。"},
{"role": "user", "content": "這台搭載處理器:Arm 20 核心(10× Cortex-X925 + 10× Cortex-A725)晶片的工作站建置vLLM提供給hermes agent有何看法?"}
],
"temperature": 0.7,
"stream": true
}' | python3 -c "
import sys, json
for line in sys.stdin:
line = line.strip()
if line.startswith('data: '):
data_str = line[6:]
if data_str == '[DONE]':
break
try:
data = json.loads(data_str)
content = data['choices'][0]['delta'].get('content', '')
print(content, end='', flush=True)
except Exception:
pass
"
#LiteLLM 轉發測試 ~chatgpt mode[jash_TEST key]
curl -s -N http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-_nhcyv5DBD7L1pTY_-1ykg" \
-d '{
"model": "Qwen3.6-35B-FP4",
"messages": [
{"role": "system", "content": "你是一位精通 AI 硬體與 Agent 架構的資深架構師。請一律使用「繁體中文(台灣)」為使用者解答,並保持專業與親切。"},
{"role": "user", "content": "這台搭載處理器:Arm 20 核心(10× Cortex-X925 + 10× Cortex-A725)晶片的工作站建置vLLM提供給hermes agent有何看法?"}
],
"temperature": 0.7,
"stream": true
}' | python3 -c "
import sys, json
for line in sys.stdin:
line = line.strip()
if line.startswith('data: '):
data_str = line[6:]
if data_str == '[DONE]':
break
try:
data = json.loads(data_str)
content = data['choices'][0]['delta'].get('content', '')
print(content, end='', flush=True)
except Exception:
pass
"
#計算每秒tokem數量
docker logs --tail 100 -f vllm-qwen
#核心效能指標分析
每秒生成 Token 數 (Generation / Decoding 速度): 模型在開始穩定吐字後,生成速度穩定落在 23.6 t/s ~ 27.3 tokens/s 之間,平均約為 25.5 tokens/s。
💡 這速度代表什麼?
人類的正常閱讀速度大約是每秒 5~10 個 Token。這台工作站的輸出速度大約是人類閱讀速度的 2.5 ~ 5 倍,體驗上會覺得字體「刷刷刷」地飛快噴出,非常流暢!對於 35B(350億參數)這樣的中大型模型來說,單卡能跑出 25+ t/s 的成績,表現相當驚艷。
首字預吞吐量 (Prompt / Prefill 速度): 在第一秒(09:13:03)導入 Prompt 進去時,吞吐量為 9.5 tokens/s。
記憶體與併發潛力 (GPU KV Cache Usage):
在整個長達 2 分多鐘的推導過程中,GPU KV 快取佔用率僅僅從 0.1% 上升到 0.2%。
這意味著您的 GPU VRAM 還有極其恐怖的剩餘空間。單一用戶只塞滿了 0.2% 的 KV 緩存,理論上這台機器可以同時輕鬆應對數百個用戶同時進行高併發對話,而不會發生顯存溢出(OOM)。
008.測試Open WebUI
http://127.0.0.1:3000/ [第一次建立管理者]
建立管理者:altos
email:altos@example.com
密碼:Altosgb10f1
http://127.0.0.1:3000/ [登入使用]
今天台北的天氣 [在輸入訊息的對話框下方「+ (加號)」 的圖標的旁邊圖示「integrations」內的 Web Search (網頁搜尋) 打開]
========================================
#docker images 熱備份
docker images #查詢目前使用狀態
# 設定目錄
BACKUP_DIR="/data/docker_backups"
mkdir -p "$BACKUP_DIR"
# 直接指定你要備份的 7 個使用中映像檔
IMAGES=(
"ghcr.io/berriai/litellm:main-v1.60.0"
"ghcr.io/open-webui/open-webui:main"
"postgres:16-alpine"
"redis:7-alpine"
"searxng/searxng:latest"
"vllm/vllm-openai:latest"
"vllm/vllm-openai:latest-aarch64"
)
# 執行備份
for image in "${IMAGES[@]}"; do
safe_name=$(echo "$image" | tr '/:' '__')
echo "正在備份 $image 到 ${BACKUP_DIR}/${safe_name}.tar ..."
docker save -o "${BACKUP_DIR}/${safe_name}.tar" "$image"
done
echo "🎉 7個映像檔全部備份完畢!"