Hướng dẫn setup llama.cpp server trên Docker + cấu hình OpenClaw — hoàn toàn offline, không cần API key
Bài này hướng dẫn bạn chạy một LLM local (Qwen3.6 35B) trên máy chủ (Ubuntu) bằng Docker llama.cpp, sau đó kết nối vào OpenClaw để dùng như một AI assistant cá nhân.
| Loại task | Decode TPS | TTFT | Mô tả |
|---|---|---|---|
| 📝 Narrative | ~134 tok/s | ~68ms | Tạo văn bản tự nhiên, trả lời câu hỏi |
| 💻 Code | ~177 tok/s | ~83ms | Sinh code, script |
GPU usage: ~21GB/24GB VRAM, utilization ~88%, công suất ~289W
Cấu trúc hệ thống:
services:
llama-cpp-qwen36-35b-a3b-mtp:
image: docker.io/eav782021/llama-cpp:mtp-cuda
container_name: llama-cpp-qwen36-35b-a3b-mtp
restart: unless-stopped
runtime: nvidia
ports:
- "8020:8080"
volumes:
- /path/to/models-cache:/models
environment:
LLAMA_CACHE: /models/llama-cache
entrypoint:
- bash
- -c
- |
set -e
EXTRA_ARGS=()
if [ "$${DISABLE_THINKING:-0}" = "1" ]; then
EXTRA_ARGS+=("--chat-template-kwargs" '{"enable_thinking":false}')
echo "[entrypoint] DISABLE_THINKING=1"
fi
exec /app/llama-server "$$@" "$${EXTRA_ARGS[@]}"
- --
command:
- --host
- 0.0.0.0
- --port
- "8080"
- -hf
- unsloth/Qwen3.6-35B-A3B-MTP-GGUF:UD-Q3_K_XL
- -c
- "229376"
- -b
- "2048"
- -ub
- "512"
- -ngl
- "99"
- -fa
- "on"
- --cache-type-k
- q4_0
- --cache-type-v
- q4_0
- -np
- "1"
- --spec-type
- draft-mtp
- --spec-draft-n-max
- "3"
- --jinja
- --reasoning-format
- none
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ["0"]
capabilities: [compute, utility]
cd /path/to/folder/ docker compose pull docker compose up -d
curl http://localhost:8020/health
# Phản hồi: {"status": "ok"}
Thêm vào file openclaw.json để OpenClaw kết nối tới server llama.cpp:
"models": {
"providers": {
"llama-cpp": {
"baseUrl": "http://IP_MAY_CHU:8020/v1",
"api": "openai-completions",
"apiKey": "sk-not-needed", // llama.cpp không cần API key
"request": {
"allowPrivateNetwork": true
},
"models": [
{
"id": "unsloth/Qwen3.6-35B-A3B-MTP-GGUF:UD-Q3_K_XL",
"name": "unsloth/Qwen3.6-35B-A3B-MTP-GGUF:UD-Q3_K_XL",
"reasoning": false,
"input": ["text"],
"contextWindow": 229376,
"maxTokens": 32768
}
]
}
}
}
openclaw config set agents.defaults.model.primary "llama-cpp/unsloth/Qwen3.6-35B-A3B-MTP-GGUF:UD-Q3_K_XL" openclaw gateway restart
Trong Telegram:
/status # Phải thấy: Model: unsloth/Qwen3.6-35B-A3B-MTP-GGUF:UD-Q3_K_XL
Gửi thử tin nhắn: "Xin chào" — nếu server phản hồi, bạn đã thành công! 🎉
nvidia-container-toolkit:
sudo nvidia-ctk runtime configure --runtime=docker && sudo systemctl restart docker
restart: unless-stopped trong docker-compose để container tự động chạy lại khi server reboot.