MLC LLM 本地部署配置
通用 LLM 部署引擎,支持移动端(iOS/Android)、浏览器(WebGPU)和本地推理
系统要求
| 项目 |
最低要求 |
推荐 |
| Python |
3.8+ |
3.10+ |
| GPU |
NVIDIA / Apple Silicon / Vulkan |
— |
| 内存 |
8 GB |
16 GB+ |
安装
pip 安装
CLI 使用
| Bash |
|---|
| # 对话(自动下载模型)
mlc_llm chat HF://mlc-ai/Qwen2.5-1.5B-Instruct-q4f16_1-MLC
# 指定 GPU
mlc_llm chat HF://mlc-ai/Qwen2.5-1.5B-Instruct-q4f16_1-MLC --device cuda
# Apple Silicon
mlc_llm chat HF://mlc-ai/Qwen2.5-1.5B-Instruct-q4f16_1-MLC --device metal
|
REST API 服务
| Bash |
|---|
| mlc_llm serve HF://mlc-ai/Qwen2.5-1.5B-Instruct-q4f16_1-MLC \
--host 0.0.0.0 \
--port 8000
|
| Bash |
|---|
| curl http://localhost:8000/v1/chat/completions -d '{
"model": "Qwen2.5-1.5B-Instruct",
"messages": [{"role": "user", "content": "你好"}]
}'
|
移动端部署
iOS
| Bash |
|---|
| # 编译 iOS App
mlc_llm compile HF://mlc-ai/Qwen2.5-1.5B-Instruct-q4f16_1-MLC --target iphone
mlc_llm package --target iphone
|
Android
| Bash |
|---|
| mlc_llm compile HF://mlc-ai/Qwen2.5-1.5B-Instruct-q4f16_1-MLC --target android
mlc_llm package --target android
|
Web 浏览器部署
| Bash |
|---|
| # 编译为 WebGPU
mlc_llm compile HF://mlc-ai/Qwen2.5-1.5B-Instruct-q4f16_1-MLC --target webgpu
# 在浏览器中运行
mlc_llm serve --target webgpu
|
练习清单