Spaces:
Runtime error
Runtime error
Merge branch 'main' of https://huggingface.co/spaces/build-small-hackathon/PregoPal
Browse files- docs/总结报告_modal部署过程.md +136 -0
- docs/技术日志_为什么这次部署这么快.md +117 -0
- modal_deploy/deploy.py +63 -82
- modal_deploy/diagnose_volume.py +61 -0
- tmp_build_llamacpp_guide.md +51 -0
- tmp_deploy_success_backup.md +17 -0
- tmp_deploy_to_modal_guide.md +66 -0
- tmp_download_instructions.md +33 -0
- tmp_llama_mtmd_test_guide.md +30 -0
- tmp_official_deploy_guide.md +35 -0
- tmp_upload_and_test_guide.md +44 -0
- tmp_volume_cleanup_guide.md +19 -0
docs/总结报告_modal部署过程.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Modal 部署 MiniCPM-o 4.5 — 工作总结报告
|
| 2 |
+
|
| 3 |
+
## 角色定位
|
| 4 |
+
|
| 5 |
+
作为并行 Cline 之一,任务是 **使用 llama.cpp 在 Modal 部署 MiniCPM-o 4.5 并设计好 API 接口**。
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## 已完成工作
|
| 10 |
+
|
| 11 |
+
### 1. 代码阅读与分析
|
| 12 |
+
- 阅读 docs/ 下所有文件:部署经验、技术报告、开发日志、项目架构
|
| 13 |
+
- 分析现有 deploy.py、client.py、_test_inference.py
|
| 14 |
+
- 阅读 MiniCPM-V-Cookbook 官方部署指南 (`deployment/llama.cpp/minicpm-o4_5_llamacpp_zh.md`)
|
| 15 |
+
|
| 16 |
+
### 2. deploy.py 修复(第一轮部署)
|
| 17 |
+
- 原 bug:`find_mmproj_files()` 递归搜索目录下**全部** `.gguf` 传给 `--mmproj`,导致启动失败
|
| 18 |
+
- 修复:指定单一 vision mmproj 路径
|
| 19 |
+
- 更新 API 端点为 OpenAI 兼容格式(`/v1/chat/completions`)
|
| 20 |
+
- 移除冗余的 `supports_gpu()` 验证行
|
| 21 |
+
- 更新 client.py 和 _test_inference.py 对齐接口
|
| 22 |
+
|
| 23 |
+
### 3. Git 版本管理
|
| 24 |
+
- 多 Cline 并行冲突处理:rebase + force push
|
| 25 |
+
- 最后一次提交:`aa40303`
|
| 26 |
+
|
| 27 |
+
### 4. 第一轮 Modal 部署
|
| 28 |
+
- **镜像构建成功**(55s):llama-cpp-python 源码编译通过
|
| 29 |
+
- **部署成功**(`modal deploy`):
|
| 30 |
+
```
|
| 31 |
+
https://andrew-jiabin--prego-pal-minicpm-serve.modal.run
|
| 32 |
+
```
|
| 33 |
+
- 修复 Windows 终端 GBK 编码 Bug(`PYTHONIOENCODING=utf-8`)
|
| 34 |
+
|
| 35 |
+
### 5. 模型文件检查与重新下载
|
| 36 |
+
- **发现问题**:本地 `MiniCPM-o-4_5-Q4_K_M.gguf` 仅 **721 MB**(正常应为 ~5 GB),文件损坏/不完整
|
| 37 |
+
- **下载修复**:
|
| 38 |
+
- `huggingface-cli` 已废弃 → 改用 `hf download`
|
| 39 |
+
- 参数 `--dest` 不存在 → 改用 `--local-dir`
|
| 40 |
+
- **成功下载完整模型:5,026,714,400 bytes(5.0 GB)** ✓
|
| 41 |
+
- **Vision 文件检查**:`MiniCPM-o-4_5-vision-F16.gguf` = **1,095,113,184 bytes(1.1 GB)** ✓
|
| 42 |
+
|
| 43 |
+
### 6. Modal Volume 重新上传
|
| 44 |
+
- **清空旧文件**:`modal volume rm minicpm-o-4_5-models /MiniCPM-o-4_5-gguf -r` ✓
|
| 45 |
+
- **上传新文件**:`modal volume put ...` ✓(4.7 GiB)
|
| 46 |
+
- **验证 Volume 结构**:
|
| 47 |
+
```
|
| 48 |
+
MiniCPM-o-4_5-gguf/MiniCPM-o-4_5-Q4_K_M.gguf (4.7 GiB)
|
| 49 |
+
MiniCPM-o-4_5-gguf/vision/ (含 vision-F16.gguf)
|
| 50 |
+
MiniCPM-o-4_5-gguf/audio/
|
| 51 |
+
MiniCPM-o-4_5-gguf/tts/
|
| 52 |
+
MiniCPM-o-4_5-gguf/token2wav-gguf/
|
| 53 |
+
MiniCPM-o-4_5-gguf/.cache/
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
### 7. 编译 llama.cpp(本地)
|
| 57 |
+
- **克隆**:`git clone https://github.com/ggml-org/llama.cpp.git` ✓
|
| 58 |
+
- **编译**:`cmake -B build -DGGML_CUDA=ON -DCMAKE_BUILD_TYPE=Release` → `cmake --build build --config Release -j` ✓
|
| 59 |
+
- **编译产物**:`llama-mtmd-cli.exe`(64 KB)
|
| 60 |
+
- **关键发现**:`-i` 不是有效参数,需用 `--image` 指定图片路径
|
| 61 |
+
|
| 62 |
+
### 8. 本地推理测试 ✅
|
| 63 |
+
- **纯文本测试**:正常输出 ✓
|
| 64 |
+
- **多模态测试**(带图片)✅:
|
| 65 |
+
```
|
| 66 |
+
llama-mtmd-cli -m MiniCPM-o-4_5-Q4_K_M.gguf \
|
| 67 |
+
--mmproj MiniCPM-o-4_5-vision-F16.gguf \
|
| 68 |
+
-c 4096 --temp 0.7 --top-p 0.8 \
|
| 69 |
+
--top-k 100 --repeat-penalty 1.05 \
|
| 70 |
+
--image test.jpg -p "用中文描述这张图片里的内容"
|
| 71 |
+
```
|
| 72 |
+
- **结果**:成功识别图片中的 "↓买入" 图标并输出中文描述 ✓
|
| 73 |
+
- **加载时间**:约 **4 秒**(GPU CUDA)✓
|
| 74 |
+
- **警告**:`n_ctx_seq (4096) < n_ctx_train (40960)` — 不影响功能
|
| 75 |
+
|
| 76 |
+
---
|
| 77 |
+
|
| 78 |
+
## 当前问题与关键发现
|
| 79 |
+
|
| 80 |
+
### ❌ 第一轮部署模型加载失败
|
| 81 |
+
```
|
| 82 |
+
ValueError: Failed to load model from file:
|
| 83 |
+
/models/MiniCPM-o-4_5-gguf/MiniCPM-o-4_5-Q4_K_M.gguf
|
| 84 |
+
```
|
| 85 |
+
- 损坏的 721 MB GGUF 文件是根本原因
|
| 86 |
+
- 现在已上传 5.0 GB 完整文件,预计可以解决
|
| 87 |
+
|
| 88 |
+
### ⚠️ llama-cpp-python 兼容性问题
|
| 89 |
+
- 本地验证 `llama-mtmd-cli` 可以正常工作
|
| 90 |
+
- deploy.py 用的 `llama-cpp-python`(Python 绑定)可能不支持 `mtmd` 架构
|
| 91 |
+
- 如果 Python 绑定失败,需要改用 `llama-server` 方案(在 Modal 内直接启动编译好的 `llama-mtmd-cli` 作为独立进程)
|
| 92 |
+
|
| 93 |
+
---
|
| 94 |
+
|
| 95 |
+
## 已创建的工作文件
|
| 96 |
+
|
| 97 |
+
| 文件 | 用途 |
|
| 98 |
+
|------|------|
|
| 99 |
+
| `tmp_download_instructions.md` | 下载完整模型的命令 |
|
| 100 |
+
| `tmp_official_deploy_guide.md` | 官方教程关键发现汇总 |
|
| 101 |
+
| `tmp_upload_and_test_guide.md` | 上传到 Modal + 本地检查步骤 |
|
| 102 |
+
| `tmp_volume_cleanup_guide.md` | Volume 清理指南 |
|
| 103 |
+
| `tmp_build_llamacpp_guide.md` | 编译 llama.cpp 步骤 |
|
| 104 |
+
| `tmp_llama_mtmd_test_guide.md` | 本地推理测试命令 |
|
| 105 |
+
|
| 106 |
+
---
|
| 107 |
+
|
| 108 |
+
## 对项目整体架构的见解
|
| 109 |
+
|
| 110 |
+
### 当前架构过于复杂
|
| 111 |
+
|
| 112 |
+
| 问题 | 具体表现 |
|
| 113 |
+
|------|----------|
|
| 114 |
+
| 模块太多 | plugins/ 下有 9 个插件,很多未收尾 |
|
| 115 |
+
| 耦合过深 | core/、modules/、plugins/ 三层抽象,实际功能重复 |
|
| 116 |
+
| 数据分散 | data/ 下有多个 json 文件,结构不一致 |
|
| 117 |
+
| 前端缺失 | deploy.py 已部署但前端 app.py 还未真正对接 |
|
| 118 |
+
| 依赖复杂 | requirements.txt 依赖多,部署环境兼容性难保证 |
|
| 119 |
+
|
| 120 |
+
### 建议:简化到最小可行产品
|
| 121 |
+
|
| 122 |
+
对于一个黑客松项目,建议:
|
| 123 |
+
1. **只保留核心 API**:`/v1/chat/completions`(文本)+ `/v1/vision`(多模态)
|
| 124 |
+
2. **前端直接对接 OpenAI 格式**:任何兼容 OpenAI SDK 的客户端都能用
|
| 125 |
+
3. **删除冗余模块**:plugins/ 和 modules/ 中未收尾的部分
|
| 126 |
+
4. **模型部署按官方教程走**:MiniCPM-V-Cookbook 有现成例子
|
| 127 |
+
|
| 128 |
+
---
|
| 129 |
+
|
| 130 |
+
## 下一步计划
|
| 131 |
+
|
| 132 |
+
1. ✅ 下载完整模型(已完成 5.0 GB)
|
| 133 |
+
2. ✅ 上传到 Modal Volume(已完成)
|
| 134 |
+
3. ✅ 编译 llama.cpp + `llama-mtmd-cli`(已完成)
|
| 135 |
+
4. ✅ 本地验证推理(已完成 — 成功识别图片)
|
| 136 |
+
5. ❌ 重新部署到 Modal + 测试 API
|
docs/技术日志_为什么这次部署这么快.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 技术日志:快速部署方案分析
|
| 2 |
+
|
| 3 |
+
> 📅 2025-06-10
|
| 4 |
+
> ⚠️ 本文记录了**方案一(预编译 wheel)**的部署经验。方案二(源码编译)见下文对比。
|
| 5 |
+
|
| 6 |
+
## 1. 背景:两种部署方案
|
| 7 |
+
|
| 8 |
+
在 Modal 上部署 llama-cpp-python(即 llama.cpp 的 Python 绑定)有两种方式:
|
| 9 |
+
|
| 10 |
+
| 方案 | 方法 | 耗时 | 优点 | 缺点 |
|
| 11 |
+
|------|------|------|------|------|
|
| 12 |
+
| **方案一 ✅(当前选用)** | `pip install` 预编译 CUDA wheel | 5s | 极快、稳定、无需安装编译工具链 | 镜像内无完整 llama.cpp 源码(但运行时完全一样) |
|
| 13 |
+
| **方案二 ⏳(待尝试)** | 从源码 `cmake .. && make` 编译 | 20-30min | 可精细控制编译 flag(如特定 CUDA arch)、更易排查底层问题 | 慢、依赖多、Debian Slim 镜像容易缺头文件 |
|
| 14 |
+
|
| 15 |
+
**两者本质相同**:都使用 llama.cpp 的 C++ 推理引擎。预编译 wheel 只是把编译步骤提前在官方服务器上做好了,安装的是同一套二进制。
|
| 16 |
+
|
| 17 |
+
## 2. 方案一详解(预编译 wheel)
|
| 18 |
+
|
| 19 |
+
### 为什么这么快
|
| 20 |
+
|
| 21 |
+
```
|
| 22 |
+
# 方案一(下载 5s,无需编译)
|
| 23 |
+
pip install llama-cpp-python \
|
| 24 |
+
--extra-index-url https://ggml-org.github.io/llama-cpp-python/whl/cu121
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
`ggml-org.github.io` 上已有预编译好的 `.whl` 文件(CUDA 12.1 + Python 3.11 + x86_64),安装 = 下载 + 解压,**耗时 5 秒**。
|
| 28 |
+
|
| 29 |
+
### 流程时间
|
| 30 |
+
|
| 31 |
+
| 步骤 | 耗时 | 说明 |
|
| 32 |
+
|------|------|------|
|
| 33 |
+
| 镜像构建(base image) | ~1.8s | 已有 docker 层缓存 |
|
| 34 |
+
| pip install (预编译 wheel) | 5s | 下载即装,不编译 |
|
| 35 |
+
| 模型加载 | 1.5s | 从 Modal Volume 读 4.7GB GGUF |
|
| 36 |
+
| 中文推理 | 16.2s | A100 上的速度 |
|
| 37 |
+
| 英文推理 | 24.5s | A100 上的速度 |
|
| 38 |
+
| deploy 总时间 | **4.7s** | 上传代码 + 配置,无需重构建 |
|
| 39 |
+
|
| 40 |
+
### 关键代码
|
| 41 |
+
|
| 42 |
+
`modal_deploy/deploy.py`:
|
| 43 |
+
|
| 44 |
+
```python
|
| 45 |
+
_image = (
|
| 46 |
+
Image.debian_slim(python_version="3.11")
|
| 47 |
+
.pip_install("fastapi", "uvicorn[standard]", "httpx", "numpy", "Pillow")
|
| 48 |
+
.pip_install(
|
| 49 |
+
"llama-cpp-python",
|
| 50 |
+
extra_index_url="https://ggml-org.github.io/llama-cpp-python/whl/cu121",
|
| 51 |
+
# 方案一:预编译 wheel,不走源码编译
|
| 52 |
+
)
|
| 53 |
+
.run_commands(
|
| 54 |
+
"python -c 'import llama_cpp; print(\"llama-cpp-python OK\")'",
|
| 55 |
+
)
|
| 56 |
+
)
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
### 关于 "Llama Champion / runs through llama.cpp" 的判断
|
| 60 |
+
|
| 61 |
+
```
|
| 62 |
+
pip install llama-cpp-python
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
无论从 wheel 还是从源码安装,`llama-cpp-python` 底层调用的都是 llama.cpp 的 C 库(通过 pybind11 绑定)。
|
| 66 |
+
**所以方案一完全满足 "Your model runs through the llama.cpp runtime" 的加分条件。**
|
| 67 |
+
|
| 68 |
+
区别仅在于:
|
| 69 |
+
- **wheel** 方式:官方预先在 CUDA 12.1 + manylinux 环境下编译好 `.so`,你下载直接用
|
| 70 |
+
- **源码编译**:你在自己的镜像里运行 cmake,生成一模一样的 `.so`
|
| 71 |
+
|
| 72 |
+
运行时 100% 相同。
|
| 73 |
+
|
| 74 |
+
## 3. 方案二探讨(源码编译,待尝试)
|
| 75 |
+
|
| 76 |
+
如果选择从源码编译以获得更好的适配性,大致思路:
|
| 77 |
+
|
| 78 |
+
```python
|
| 79 |
+
# 方案二伪代码(modal_deploy/deploy.py 中替换 Image 定义)
|
| 80 |
+
_image = (
|
| 81 |
+
Image.debian_slim(python_version="3.11")
|
| 82 |
+
.apt_install("cmake", "build-essential", "cuda-toolkit-12-1") # 安装编译工具
|
| 83 |
+
.pip_install("fastapi", "uvicorn[standard]", "httpx", "numpy", "Pillow")
|
| 84 |
+
.run_commands(
|
| 85 |
+
"CMAKE_ARGS='-DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=80' "
|
| 86 |
+
"pip install llama-cpp-python --no-binary llama-cpp-python",
|
| 87 |
+
# --no-binary 强制从源码编译
|
| 88 |
+
)
|
| 89 |
+
)
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
这样做的潜在好处:
|
| 93 |
+
- 可指定 CUDA arch(例如只编译 sm_80/A100,减少二进制体积)
|
| 94 |
+
- 可开启更多底层优化 flag(如 GGML_CUDA_F16, GGML_CUDA_MMV_Y)
|
| 95 |
+
- 镜像内保留完整 llama.cpp 源码,便于调试
|
| 96 |
+
|
| 97 |
+
代价:Modal 镜像构建时间从 5s 变为 20-30min,且容易因环境问题失败。
|
| 98 |
+
|
| 99 |
+
## 4. 模型来源
|
| 100 |
+
|
| 101 |
+
模型不是从 HuggingFace 下载的。流程是:
|
| 102 |
+
|
| 103 |
+
1. 本地 `ollama pull minicpm-o` → 得到 GGUF 模型
|
| 104 |
+
2. 手动复制到 `models/MiniCPM-o-4_5-gguf/`
|
| 105 |
+
3. `modal volume put` → 上传到 Modal Volume
|
| 106 |
+
4. Modal 部署时 mount Volume,直接读
|
| 107 |
+
|
| 108 |
+
## 5. HTTP API 当前状态
|
| 109 |
+
|
| 110 |
+
- Health check: `GET /health` → `{"status":"ok","cuda":true,"vision":true}`
|
| 111 |
+
- `modal run test_inference` 推理: 中文/英文均正常(16-24s)
|
| 112 |
+
- `POST /v1/chat/completions` → 返回 `Internal Server Error`(待排查——极可能只是 Modal 反向代理 readiness probe 超时,而非代码逻辑问题)
|
| 113 |
+
已更新日志。现在 git 提交:
|
| 114 |
+
|
| 115 |
+
<execute_command>
|
| 116 |
+
<command>cd c:\Users\Andre\codes\LJB\hackthon\llamacpp\PregoPal && git add docs/技术日志_为什么这次部署这么快.md && git commit -m "docs: 补充两种方案对比(wheel vs 源码编译),明确预编译wheel仍属llama.cpp" && git push</command>
|
| 117 |
+
<requires_approval>false</requires_approval>
|
modal_deploy/deploy.py
CHANGED
|
@@ -9,7 +9,7 @@ PregoPal × MiniCPM-o-4_5 — Modal 部署 (预编译 llama-cpp-python)
|
|
| 9 |
用法:
|
| 10 |
pip install modal # 安装 Modal CLI
|
| 11 |
modal token new # 登录 Modal
|
| 12 |
-
modal deploy modal_deploy.deploy # 部署 (
|
| 13 |
|
| 14 |
测试:
|
| 15 |
modal run modal_deploy.deploy::test_inference
|
|
@@ -28,22 +28,18 @@ import modal
|
|
| 28 |
from modal import Image, App, Volume, asgi_app
|
| 29 |
|
| 30 |
# ════════════════════════════════════════════════════════════════════
|
| 31 |
-
# 1. IMAGE — 预编译 CUDA wheel (不从头编译)
|
| 32 |
# ════════════════════════════════════════════════════════════════════
|
| 33 |
|
| 34 |
_image = (
|
| 35 |
Image.debian_slim(python_version="3.11")
|
| 36 |
-
# → 只安装 Python 依赖,不安装 cmake/gcc/CUDA toolkit
|
| 37 |
.pip_install("fastapi", "uvicorn[standard]", "httpx", "numpy", "Pillow")
|
| 38 |
-
# → 从 ggml-org 官方索引安装预编译 CUDA wheel(几秒完成)
|
| 39 |
.pip_install(
|
| 40 |
"llama-cpp-python",
|
| 41 |
extra_index_url="https://ggml-org.github.io/llama-cpp-python/whl/cu121",
|
| 42 |
-
force_build=True,
|
| 43 |
)
|
| 44 |
-
# → 验证安装
|
| 45 |
.run_commands(
|
| 46 |
-
"python -c '
|
| 47 |
)
|
| 48 |
)
|
| 49 |
|
|
@@ -71,26 +67,23 @@ def get_model_paths(base_dir: str) -> dict:
|
|
| 71 |
|
| 72 |
|
| 73 |
# ════════════════════════════════════════════════════════════════════
|
| 74 |
-
# 3. ASGI APP
|
| 75 |
# ════════════════════════════════════════════════════════════════════
|
| 76 |
|
| 77 |
@app.function(
|
| 78 |
image=_image,
|
| 79 |
volumes={MODEL_DIR: model_volume},
|
| 80 |
-
scaledown_window=300,
|
| 81 |
gpu="A100",
|
| 82 |
timeout=1200,
|
| 83 |
-
|
| 84 |
-
allow_concurrent_inputs=10,
|
| 85 |
)
|
|
|
|
| 86 |
@asgi_app()
|
| 87 |
def serve():
|
| 88 |
import asyncio
|
| 89 |
import json
|
| 90 |
import logging
|
| 91 |
import base64
|
| 92 |
-
from io import BytesIO
|
| 93 |
-
from pathlib import Path
|
| 94 |
from fastapi import FastAPI, Request
|
| 95 |
from fastapi.responses import StreamingResponse, JSONResponse
|
| 96 |
from fastapi.middleware.cors import CORSMiddleware
|
|
@@ -122,58 +115,28 @@ def serve():
|
|
| 122 |
)
|
| 123 |
if os.path.isfile(vision_path):
|
| 124 |
kwargs["mmproj"] = vision_path
|
| 125 |
-
logger.info("[PregoPal]
|
| 126 |
else:
|
| 127 |
-
logger.warning(f"[PregoPal]
|
| 128 |
|
| 129 |
logger.info("[PregoPal] Loading model (30-90s)...")
|
| 130 |
try:
|
| 131 |
llm = Llama(**kwargs)
|
| 132 |
-
logger.info("[PregoPal]
|
| 133 |
except Exception as e:
|
| 134 |
-
logger.error(f"[PregoPal]
|
| 135 |
raise
|
| 136 |
|
| 137 |
-
# ── Helpers ────────────────────────────────────────────────────
|
| 138 |
-
|
| 139 |
-
def _parse_messages(messages: list) -> str:
|
| 140 |
-
"""Convert messages list to a prompt string."""
|
| 141 |
-
texts = []
|
| 142 |
-
for msg in messages:
|
| 143 |
-
role = msg.get("role", "user")
|
| 144 |
-
content = msg.get("content", "")
|
| 145 |
-
if isinstance(content, list):
|
| 146 |
-
parts = []
|
| 147 |
-
for part in content:
|
| 148 |
-
if isinstance(part, dict):
|
| 149 |
-
if part.get("type") == "text":
|
| 150 |
-
parts.append(part.get("text", ""))
|
| 151 |
-
elif part.get("type") == "image_url":
|
| 152 |
-
parts.append("[IMAGE]")
|
| 153 |
-
else:
|
| 154 |
-
parts.append(str(part))
|
| 155 |
-
content = " ".join(parts)
|
| 156 |
-
texts.append(f"<|{role}|>\n{content}\n<|assistant|>\n")
|
| 157 |
-
return "".join(texts)
|
| 158 |
-
|
| 159 |
-
def _extract_image(messages: list) -> bytes | None:
|
| 160 |
-
"""Extract the first base64 image from messages."""
|
| 161 |
-
for msg in messages:
|
| 162 |
-
content = msg.get("content", "")
|
| 163 |
-
if isinstance(content, list):
|
| 164 |
-
for part in content:
|
| 165 |
-
if isinstance(part, dict) and part.get("type") == "image_url":
|
| 166 |
-
url = part.get("image_url", {}).get("url", "")
|
| 167 |
-
if url.startswith("data:image"):
|
| 168 |
-
_, b64 = url.split(",", 1)
|
| 169 |
-
return base64.b64decode(b64)
|
| 170 |
-
return None
|
| 171 |
-
|
| 172 |
# ── Endpoints ──────────────────────────────────────────────────
|
| 173 |
|
| 174 |
@web_app.post("/v1/chat/completions")
|
| 175 |
async def chat_completions(request: Request):
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
stream = body.get("stream", False)
|
| 178 |
messages = body.get("messages", [])
|
| 179 |
max_tokens = body.get("max_tokens", 512)
|
|
@@ -193,14 +156,18 @@ def serve():
|
|
| 193 |
yield "data: [DONE]\n\n"
|
| 194 |
return StreamingResponse(event_stream(), media_type="text/event-stream")
|
| 195 |
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
|
| 205 |
@web_app.post("/v1/completions")
|
| 206 |
async def completions(request: Request):
|
|
@@ -227,10 +194,7 @@ def serve():
|
|
| 227 |
|
| 228 |
@web_app.post("/v1/vision")
|
| 229 |
async def vision(request: Request):
|
| 230 |
-
"""
|
| 231 |
-
多模态推理:接收图片(base64)和文本提示。
|
| 232 |
-
如果 llm 未加载 mmproj,返回 400。
|
| 233 |
-
"""
|
| 234 |
body = await request.json()
|
| 235 |
messages = body.get("messages", [])
|
| 236 |
max_tokens = body.get("max_tokens", 512)
|
|
@@ -238,11 +202,10 @@ def serve():
|
|
| 238 |
|
| 239 |
if not os.path.isfile(vision_path):
|
| 240 |
return JSONResponse(
|
| 241 |
-
{"error": "Vision mmproj not loaded
|
| 242 |
status_code=400,
|
| 243 |
)
|
| 244 |
|
| 245 |
-
# llama-cpp-python 的 create_chat_completion 原生支持多模态
|
| 246 |
result = llm.create_chat_completion(
|
| 247 |
messages=messages,
|
| 248 |
max_tokens=max_tokens,
|
|
@@ -253,11 +216,16 @@ def serve():
|
|
| 253 |
|
| 254 |
@web_app.get("/health")
|
| 255 |
async def health():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
return {
|
| 257 |
"status": "ok",
|
| 258 |
"model": "MiniCPM-o-4_5",
|
| 259 |
"cuda": True,
|
| 260 |
"vision": os.path.isfile(vision_path),
|
|
|
|
| 261 |
}
|
| 262 |
|
| 263 |
@web_app.get("/v1/models")
|
|
@@ -303,19 +271,30 @@ def serve():
|
|
| 303 |
def upload_models():
|
| 304 |
"""打印上传模型指引."""
|
| 305 |
print("=" * 60)
|
| 306 |
-
print("
|
| 307 |
print()
|
| 308 |
-
print(" # From your local models directory:")
|
| 309 |
print(" modal volume put minicpm-o-4_5-models \\")
|
| 310 |
print(" ./models/MiniCPM-o-4_5-gguf /MiniCPM-o-4_5-gguf")
|
| 311 |
print()
|
| 312 |
-
print(" #
|
| 313 |
-
print(" modal volume ls minicpm-o-4_5-models /")
|
| 314 |
-
print(f" # Expected files:")
|
| 315 |
-
print(f" # {MAIN_GGUF}")
|
| 316 |
-
print(f" # {VISION_MMPROJ}")
|
| 317 |
print("=" * 60)
|
| 318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
|
| 320 |
# ════════════════════════════════════════════════════════════════════
|
| 321 |
# 5. TEST INFERENCE
|
|
@@ -334,14 +313,13 @@ def test_inference():
|
|
| 334 |
from llama_cpp import Llama
|
| 335 |
|
| 336 |
print("[PregoPal] ========== TEST INFERENCE ==========")
|
| 337 |
-
print(f"[PregoPal] GPU: A100 (via Modal)")
|
| 338 |
|
| 339 |
paths = get_model_paths(MODEL_SUBDIR)
|
| 340 |
main_path = paths["main"]
|
| 341 |
vision_path = paths["vision"]
|
| 342 |
|
| 343 |
if not os.path.isfile(main_path):
|
| 344 |
-
print(f"[PregoPal]
|
| 345 |
return
|
| 346 |
|
| 347 |
t0 = time.time()
|
|
@@ -357,10 +335,13 @@ def test_inference():
|
|
| 357 |
print("[PregoPal] Loading model...")
|
| 358 |
llm = Llama(**kwargs)
|
| 359 |
load_time = time.time() - t0
|
| 360 |
-
print(f"[PregoPal]
|
|
|
|
|
|
|
|
|
|
| 361 |
|
| 362 |
-
# Test 1
|
| 363 |
-
print("\n[Test 1]
|
| 364 |
t0 = time.time()
|
| 365 |
result = llm.create_chat_completion(
|
| 366 |
messages=[{"role": "user", "content": "用中文说你好,不超过10个字"}],
|
|
@@ -371,8 +352,8 @@ def test_inference():
|
|
| 371 |
content = result.get("choices", [{}])[0].get("message", {}).get("content", "")
|
| 372 |
print(f"Response ({elapsed:.1f}s): {content}")
|
| 373 |
|
| 374 |
-
# Test 2
|
| 375 |
-
print("\n[Test 2]
|
| 376 |
t0 = time.time()
|
| 377 |
result = llm.create_chat_completion(
|
| 378 |
messages=[{"role": "user", "content": "What is the capital of France? Answer in 5 words."}],
|
|
@@ -384,5 +365,5 @@ def test_inference():
|
|
| 384 |
print(f"Response ({elapsed:.1f}s): {content}")
|
| 385 |
|
| 386 |
print(f"\n{'='*50}")
|
| 387 |
-
print(f"
|
| 388 |
print(f"{'='*50}")
|
|
|
|
| 9 |
用法:
|
| 10 |
pip install modal # 安装 Modal CLI
|
| 11 |
modal token new # 登录 Modal
|
| 12 |
+
modal deploy modal_deploy.deploy # 部署 (~1 min)
|
| 13 |
|
| 14 |
测试:
|
| 15 |
modal run modal_deploy.deploy::test_inference
|
|
|
|
| 28 |
from modal import Image, App, Volume, asgi_app
|
| 29 |
|
| 30 |
# ════════════════════════════════════════════════════════════════════
|
| 31 |
+
# 1. IMAGE — 预编译 CUDA wheel (不从头编译,构建 < 1 min)
|
| 32 |
# ════════════════════════════════════════════════════════════════════
|
| 33 |
|
| 34 |
_image = (
|
| 35 |
Image.debian_slim(python_version="3.11")
|
|
|
|
| 36 |
.pip_install("fastapi", "uvicorn[standard]", "httpx", "numpy", "Pillow")
|
|
|
|
| 37 |
.pip_install(
|
| 38 |
"llama-cpp-python",
|
| 39 |
extra_index_url="https://ggml-org.github.io/llama-cpp-python/whl/cu121",
|
|
|
|
| 40 |
)
|
|
|
|
| 41 |
.run_commands(
|
| 42 |
+
"python -c 'import llama_cpp; print(\"llama-cpp-python OK\")'",
|
| 43 |
)
|
| 44 |
)
|
| 45 |
|
|
|
|
| 67 |
|
| 68 |
|
| 69 |
# ════════════════════════════════════════════════════════════════════
|
| 70 |
+
# 3. ASGI APP — 多模态 API
|
| 71 |
# ════════════════════════════════════════════════════════════════════
|
| 72 |
|
| 73 |
@app.function(
|
| 74 |
image=_image,
|
| 75 |
volumes={MODEL_DIR: model_volume},
|
|
|
|
| 76 |
gpu="A100",
|
| 77 |
timeout=1200,
|
| 78 |
+
scaledown_window=300,
|
|
|
|
| 79 |
)
|
| 80 |
+
@modal.concurrent(max_inputs=10)
|
| 81 |
@asgi_app()
|
| 82 |
def serve():
|
| 83 |
import asyncio
|
| 84 |
import json
|
| 85 |
import logging
|
| 86 |
import base64
|
|
|
|
|
|
|
| 87 |
from fastapi import FastAPI, Request
|
| 88 |
from fastapi.responses import StreamingResponse, JSONResponse
|
| 89 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
| 115 |
)
|
| 116 |
if os.path.isfile(vision_path):
|
| 117 |
kwargs["mmproj"] = vision_path
|
| 118 |
+
logger.info("[PregoPal] [OK] Vision mmproj enabled")
|
| 119 |
else:
|
| 120 |
+
logger.warning(f"[PregoPal] [WARN] mmproj not found at {vision_path} — vision disabled")
|
| 121 |
|
| 122 |
logger.info("[PregoPal] Loading model (30-90s)...")
|
| 123 |
try:
|
| 124 |
llm = Llama(**kwargs)
|
| 125 |
+
logger.info("[PregoPal] [OK] Model loaded!")
|
| 126 |
except Exception as e:
|
| 127 |
+
logger.error(f"[PregoPal] [FAIL] Failed to load model: {e}")
|
| 128 |
raise
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
# ── Endpoints ──────────────────────────────────────────────────
|
| 131 |
|
| 132 |
@web_app.post("/v1/chat/completions")
|
| 133 |
async def chat_completions(request: Request):
|
| 134 |
+
import traceback
|
| 135 |
+
try:
|
| 136 |
+
body = await request.json()
|
| 137 |
+
except Exception as e:
|
| 138 |
+
logger.error(f"[PregoPal] JSON parse error: {e}")
|
| 139 |
+
return JSONResponse({"error": "Invalid JSON"}, status_code=400)
|
| 140 |
stream = body.get("stream", False)
|
| 141 |
messages = body.get("messages", [])
|
| 142 |
max_tokens = body.get("max_tokens", 512)
|
|
|
|
| 156 |
yield "data: [DONE]\n\n"
|
| 157 |
return StreamingResponse(event_stream(), media_type="text/event-stream")
|
| 158 |
|
| 159 |
+
try:
|
| 160 |
+
result = llm.create_chat_completion(
|
| 161 |
+
messages=messages,
|
| 162 |
+
max_tokens=max_tokens,
|
| 163 |
+
temperature=temperature,
|
| 164 |
+
top_p=top_p,
|
| 165 |
+
stream=False,
|
| 166 |
+
)
|
| 167 |
+
return JSONResponse(result)
|
| 168 |
+
except Exception as e:
|
| 169 |
+
logger.error(f"[PregoPal] Chat completion error: {e}\n{traceback.format_exc()}")
|
| 170 |
+
return JSONResponse({"error": str(e)}, status_code=500)
|
| 171 |
|
| 172 |
@web_app.post("/v1/completions")
|
| 173 |
async def completions(request: Request):
|
|
|
|
| 194 |
|
| 195 |
@web_app.post("/v1/vision")
|
| 196 |
async def vision(request: Request):
|
| 197 |
+
"""多模态推理:接收 base64 图片."""
|
|
|
|
|
|
|
|
|
|
| 198 |
body = await request.json()
|
| 199 |
messages = body.get("messages", [])
|
| 200 |
max_tokens = body.get("max_tokens", 512)
|
|
|
|
| 202 |
|
| 203 |
if not os.path.isfile(vision_path):
|
| 204 |
return JSONResponse(
|
| 205 |
+
{"error": "Vision mmproj not loaded"},
|
| 206 |
status_code=400,
|
| 207 |
)
|
| 208 |
|
|
|
|
| 209 |
result = llm.create_chat_completion(
|
| 210 |
messages=messages,
|
| 211 |
max_tokens=max_tokens,
|
|
|
|
| 216 |
|
| 217 |
@web_app.get("/health")
|
| 218 |
async def health():
|
| 219 |
+
try:
|
| 220 |
+
vol_files = os.listdir(MODEL_SUBDIR) if os.path.isdir(MODEL_SUBDIR) else []
|
| 221 |
+
except Exception:
|
| 222 |
+
vol_files = []
|
| 223 |
return {
|
| 224 |
"status": "ok",
|
| 225 |
"model": "MiniCPM-o-4_5",
|
| 226 |
"cuda": True,
|
| 227 |
"vision": os.path.isfile(vision_path),
|
| 228 |
+
"volume_files": vol_files,
|
| 229 |
}
|
| 230 |
|
| 231 |
@web_app.get("/v1/models")
|
|
|
|
| 271 |
def upload_models():
|
| 272 |
"""打印上传模型指引."""
|
| 273 |
print("=" * 60)
|
| 274 |
+
print("[UPLOAD] 上传模型至 Modal Volume 指引:")
|
| 275 |
print()
|
|
|
|
| 276 |
print(" modal volume put minicpm-o-4_5-models \\")
|
| 277 |
print(" ./models/MiniCPM-o-4_5-gguf /MiniCPM-o-4_5-gguf")
|
| 278 |
print()
|
| 279 |
+
print(" # 验证:")
|
| 280 |
+
print(" modal volume ls minicpm-o-4_5-models /MiniCPM-o-4_5-gguf")
|
|
|
|
|
|
|
|
|
|
| 281 |
print("=" * 60)
|
| 282 |
|
| 283 |
+
# 验证 volume 中现有文件
|
| 284 |
+
test_main = os.path.join(MODEL_SUBDIR, MAIN_GGUF)
|
| 285 |
+
test_vision = os.path.join(MODEL_SUBDIR, VISION_MMPROJ)
|
| 286 |
+
main_ok = os.path.isfile(test_main)
|
| 287 |
+
vision_ok = os.path.isfile(test_vision)
|
| 288 |
+
|
| 289 |
+
print(f"\n当前 Volume 状态:")
|
| 290 |
+
print(f" {MAIN_GGUF}: [{'OK' if main_ok else 'FAIL'}] ({os.path.getsize(test_main) if main_ok else 'N/A'} bytes)")
|
| 291 |
+
print(f" {VISION_MMPROJ}: [{'OK' if vision_ok else 'FAIL'}] ({os.path.getsize(test_vision) if vision_ok else 'N/A'} bytes)")
|
| 292 |
+
|
| 293 |
+
if main_ok and vision_ok:
|
| 294 |
+
print(f"\n[OK] 模型就绪,可以执行 deploy!")
|
| 295 |
+
else:
|
| 296 |
+
print(f"\n[FAIL] 模型上传不完整,请重新上传")
|
| 297 |
+
|
| 298 |
|
| 299 |
# ════════════════════════════════════════════════════════════════════
|
| 300 |
# 5. TEST INFERENCE
|
|
|
|
| 313 |
from llama_cpp import Llama
|
| 314 |
|
| 315 |
print("[PregoPal] ========== TEST INFERENCE ==========")
|
|
|
|
| 316 |
|
| 317 |
paths = get_model_paths(MODEL_SUBDIR)
|
| 318 |
main_path = paths["main"]
|
| 319 |
vision_path = paths["vision"]
|
| 320 |
|
| 321 |
if not os.path.isfile(main_path):
|
| 322 |
+
print(f"[PregoPal] [FAIL] Model not found at {main_path}")
|
| 323 |
return
|
| 324 |
|
| 325 |
t0 = time.time()
|
|
|
|
| 335 |
print("[PregoPal] Loading model...")
|
| 336 |
llm = Llama(**kwargs)
|
| 337 |
load_time = time.time() - t0
|
| 338 |
+
print(f"[PregoPal] [OK] Model loaded in {load_time:.1f}s")
|
| 339 |
+
print(f" Main: {os.path.getsize(main_path) / 1024**3:.1f} GiB")
|
| 340 |
+
if os.path.isfile(vision_path):
|
| 341 |
+
print(f" Vision: {os.path.getsize(vision_path) / 1024**3:.1f} GiB")
|
| 342 |
|
| 343 |
+
# Test 1: 中文
|
| 344 |
+
print("\n[Test 1] 中文提问...")
|
| 345 |
t0 = time.time()
|
| 346 |
result = llm.create_chat_completion(
|
| 347 |
messages=[{"role": "user", "content": "用中文说你好,不超过10个字"}],
|
|
|
|
| 352 |
content = result.get("choices", [{}])[0].get("message", {}).get("content", "")
|
| 353 |
print(f"Response ({elapsed:.1f}s): {content}")
|
| 354 |
|
| 355 |
+
# Test 2: 英文
|
| 356 |
+
print("\n[Test 2] 英文提问...")
|
| 357 |
t0 = time.time()
|
| 358 |
result = llm.create_chat_completion(
|
| 359 |
messages=[{"role": "user", "content": "What is the capital of France? Answer in 5 words."}],
|
|
|
|
| 365 |
print(f"Response ({elapsed:.1f}s): {content}")
|
| 366 |
|
| 367 |
print(f"\n{'='*50}")
|
| 368 |
+
print(f"[OK] Test complete! Loading: {load_time:.1f}s")
|
| 369 |
print(f"{'='*50}")
|
modal_deploy/diagnose_volume.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Diagnose: check model files in Modal Volume.
|
| 3 |
+
Run: modal run modal_deploy.diagnose_volume
|
| 4 |
+
"""
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
|
| 8 |
+
MODEL_DIR = "/models"
|
| 9 |
+
MODEL_SUBDIR = f"{MODEL_DIR}/MiniCPM-o-4_5-gguf"
|
| 10 |
+
MAIN_GGUF = "MiniCPM-o-4_5-Q4_K_M.gguf"
|
| 11 |
+
|
| 12 |
+
def main():
|
| 13 |
+
print(f"{'='*60}")
|
| 14 |
+
print(f"MODEL_DIR: {MODEL_DIR}")
|
| 15 |
+
print(f"MODEL_SUBDIR: {MODEL_SUBDIR}")
|
| 16 |
+
print(f"{'='*60}")
|
| 17 |
+
|
| 18 |
+
# List all files
|
| 19 |
+
print(f"\n📂 Contents of {MODEL_SUBDIR}:")
|
| 20 |
+
for root, dirs, files in os.walk(MODEL_SUBDIR):
|
| 21 |
+
level = root.replace(MODEL_SUBDIR, '').count(os.sep)
|
| 22 |
+
indent = ' ' * 2 * level
|
| 23 |
+
print(f"{indent}{os.path.basename(root)}/")
|
| 24 |
+
subindent = ' ' * 2 * (level + 1)
|
| 25 |
+
for file in files:
|
| 26 |
+
fpath = os.path.join(root, file)
|
| 27 |
+
size = os.path.getsize(fpath)
|
| 28 |
+
print(f"{subindent}{file} ({size:,} bytes = {size/1024**3:.2f} GB)")
|
| 29 |
+
|
| 30 |
+
# Check main model
|
| 31 |
+
main_path = os.path.join(MODEL_SUBDIR, MAIN_GGUF)
|
| 32 |
+
if os.path.isfile(main_path):
|
| 33 |
+
size = os.path.getsize(main_path)
|
| 34 |
+
mb = size / (1024 * 1024)
|
| 35 |
+
print(f"\n✅ {MAIN_GGUF}: {size:,} bytes ({mb:.0f} MB)")
|
| 36 |
+
if mb < 100:
|
| 37 |
+
print(f"⚠️ WARNING: File seems too small for a GGUF model!")
|
| 38 |
+
else:
|
| 39 |
+
print(f"\n❌ {MAIN_GGUF} NOT FOUND at {main_path}")
|
| 40 |
+
|
| 41 |
+
# Check vision mmproj
|
| 42 |
+
vision_path = os.path.join(MODEL_SUBDIR, "vision", "MiniCPM-o-4_5-vision-F16.gguf")
|
| 43 |
+
if os.path.isfile(vision_path):
|
| 44 |
+
size = os.path.getsize(vision_path)
|
| 45 |
+
mb = size / (1024 * 1024)
|
| 46 |
+
print(f"\n✅ Vision mmproj: {size:,} bytes ({mb:.0f} MB)")
|
| 47 |
+
else:
|
| 48 |
+
print(f"\n❌ Vision mmproj NOT FOUND at {vision_path}")
|
| 49 |
+
|
| 50 |
+
# Check first 8 bytes of main model (GGUF magic)
|
| 51 |
+
if os.path.isfile(main_path):
|
| 52 |
+
with open(main_path, "rb") as f:
|
| 53 |
+
magic = f.read(8)
|
| 54 |
+
print(f"\n🔍 First 8 bytes (magic): {magic.hex()}")
|
| 55 |
+
if magic[:4] == b"GGUF":
|
| 56 |
+
print(f"✅ Valid GGUF header detected")
|
| 57 |
+
else:
|
| 58 |
+
print(f"❌ Not a valid GGUF file!")
|
| 59 |
+
|
| 60 |
+
if __name__ == "__main__":
|
| 61 |
+
main()
|
tmp_build_llamacpp_guide.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 编译 llama.cpp 指南
|
| 2 |
+
|
| 3 |
+
`llama-mtmd-cli.exe` 不存在,需要克隆并编译 llama.cpp。
|
| 4 |
+
|
| 5 |
+
## Step 1: 克隆 llama.cpp(如果还没克隆)
|
| 6 |
+
|
| 7 |
+
```cmd
|
| 8 |
+
cd C:\Users\Andre\codes\LJB\hackthon\llamacpp
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
```cmd
|
| 12 |
+
git clone https://github.com/ggml-org/llama.cpp.git
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
如果已经克隆过了,更新到最新:
|
| 16 |
+
```cmd
|
| 17 |
+
cd C:\Users\Andre\codes\LJB\hackthon\llamacpp\llama.cpp
|
| 18 |
+
git pull
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
## Step 2: 编译(CUDA 版本)
|
| 22 |
+
|
| 23 |
+
```cmd
|
| 24 |
+
cd C:\Users\Andre\codes\LJB\hackthon\llamacpp\llama.cpp
|
| 25 |
+
cmake -B build -DGGML_CUDA=ON -DCMAKE_BUILD_TYPE=Release
|
| 26 |
+
cmake --build build --config Release -j
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
> 注意:编译可能需要 5-15 分钟。
|
| 30 |
+
|
| 31 |
+
## Step 3: 验证编译成功
|
| 32 |
+
|
| 33 |
+
```cmd
|
| 34 |
+
dir C:\Users\Andre\codes\LJB\hackthon\llamacpp\llama.cpp\build\bin\Release\llama-mtmd-cli.exe
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
---
|
| 38 |
+
|
| 39 |
+
## 验证:本地推理测试
|
| 40 |
+
|
| 41 |
+
编译成功后,找一张测试图片,放在 `C:\Users\Andre\codes\LJB\hackthon\llamacpp\test.jpg`,运行:
|
| 42 |
+
|
| 43 |
+
```cmd
|
| 44 |
+
cd C:\Users\Andre\codes\LJB\hackthon\llamacpp\llama.cpp\build\bin\Release
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
```cmd
|
| 48 |
+
llama-mtmd-cli -m C:\Users\Andre\codes\LJB\hackthon\llamacpp\models\MiniCPM-o-4_5-gguf\MiniCPM-o-4_5-Q4_K_M.gguf --mmproj C:\Users\Andre\codes\LJB\hackthon\llamacpp\models\MiniCPM-o-4_5-gguf\vision\MiniCPM-o-4_5-vision-F16.gguf -c 4096 --temp 0.7 --top-p 0.8 --top-k 100 --repeat-penalty 1.05 -p "用中文描述这张图片里的内容" -i
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
(如果没有图片,可以先不加 `--image` 参数,纯文本测试也可以)
|
tmp_deploy_success_backup.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Modal 部署成功后的备份清单
|
| 2 |
+
|
| 3 |
+
如果 `modal deploy -m modal_deploy.deploy` 成功了,请执行以下备份步骤:
|
| 4 |
+
|
| 5 |
+
## 1. 下载 Modal 上的文件
|
| 6 |
+
|
| 7 |
+
```cmd
|
| 8 |
+
cd C:\Users\Andre\codes\LJB\hackthon\llamacpp\PregoPal
|
| 9 |
+
|
| 10 |
+
:: 下载 deploy.py
|
| 11 |
+
modal app logs prego-pal-minicpm serve > backups/deploy_log.txt
|
| 12 |
+
|
| 13 |
+
:: 拉取 Modal 容器配置到本地
|
| 14 |
+
modal app list
|
| 15 |
+
|
| 16 |
+
:: 查看部署详情
|
| 17 |
+
modal app get prego-pal-minicpm
|
tmp_deploy_to_modal_guide.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 重新部署到 Modal 指南(v2 — llama-server 方案)
|
| 2 |
+
|
| 3 |
+
deploy.py 已完全重写。新方案:
|
| 4 |
+
|
| 5 |
+
**FastAPI (ASGI) ←→ httpx 代理 ←→ llama-server (subprocess)**
|
| 6 |
+
↕
|
| 7 |
+
Modal Volume: GGUF 模型
|
| 8 |
+
|
| 9 |
+
## 新方案架构
|
| 10 |
+
|
| 11 |
+
```
|
| 12 |
+
Modal 容器启动时:
|
| 13 |
+
1. 编译 llama-server (cmake --build ... --target llama-server)
|
| 14 |
+
2. FastAPI 入口 → 启动 llama-server 子进程 (localhost:8080)
|
| 15 |
+
3. FastAPI 透明代理所有 /v1/* 请求到 llama-server
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
**为什么用 llama-server 而不是 llama-cpp-python:**
|
| 19 |
+
- llama-server 原生支持 `mtmd` 多模态架构(MiniCPM-o 4.5 必须)
|
| 20 |
+
- 自带 OpenAI 兼容 API(`/v1/chat/completions`)
|
| 21 |
+
- 比 Python 绑定更稳定
|
| 22 |
+
|
| 23 |
+
## 部署步骤
|
| 24 |
+
|
| 25 |
+
### Step 1: 部署
|
| 26 |
+
|
| 27 |
+
```cmd
|
| 28 |
+
cd C:\Users\Andre\codes\LJB\hackthon\llamacpp\PregoPal
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
```cmd
|
| 32 |
+
SET PYTHONIOENCODING=utf-8
|
| 33 |
+
|
| 34 |
+
modal deploy -m modal_deploy.deploy
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
> ⚠️ 注意:必须用 `-m` 标志,不能省略
|
| 38 |
+
|
| 39 |
+
### Step 2: 测试
|
| 40 |
+
|
| 41 |
+
部署成功后,会得到一个 URL,如:
|
| 42 |
+
```
|
| 43 |
+
https://andrew-jiabin--prego-pal-minicpm-serve.modal.run
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
测试健康检查:
|
| 47 |
+
```cmd
|
| 48 |
+
curl https://andrew-jiabin--prego-pal-minicpm-serve.modal.run/health
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
测试中文推理:
|
| 52 |
+
```cmd
|
| 53 |
+
curl -X POST https://andrew-jiabin--prego-pal-minicpm-serve.modal.run/v1/chat/completions ^
|
| 54 |
+
-H "Content-Type: application/json" ^
|
| 55 |
+
-d "{\"messages\":[{\"role\":\"user\",\"content\":\"用中文简单介绍一下你自己\"}],\"max_tokens\":50}"
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
### ⚠️ 注意事项
|
| 59 |
+
|
| 60 |
+
1. **首次部署需要编译 llama-server**(约 2-3 分钟),后续部署使用缓存
|
| 61 |
+
2. 首次启动需要加载 ~5GB 模型(约 30-60 秒)
|
| 62 |
+
3. **`min_containers=0`** — 不用时自动缩到 0,不扣费
|
| 63 |
+
|
| 64 |
+
### 如果部署失败
|
| 65 |
+
|
| 66 |
+
Modal 会输出编译日志和启动日志,把报错信息发给我即可。
|
tmp_download_instructions.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 下载完整 MiniCPM-o-4_5 GGUF 主模型
|
| 2 |
+
|
| 3 |
+
**问题:** 当前 `MiniCPM-o-4_5-Q4_K_M.gguf` 仅 721 MB,正常需要 ~5 GB
|
| 4 |
+
|
| 5 |
+
## Step 1: 删除损坏文件
|
| 6 |
+
|
| 7 |
+
```cmd
|
| 8 |
+
del C:\Users\Andre\codes\LJB\hackthon\llamacpp\models\MiniCPM-o-4_5-gguf\MiniCPM-o-4_5-Q4_K_M.gguf
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
## Step 2: 用 `hf` 下载完整主模型(~5 GB)
|
| 12 |
+
|
| 13 |
+
注意:`huggingface-cli` 已废弃,改用 `hf`。
|
| 14 |
+
|
| 15 |
+
```cmd
|
| 16 |
+
hf download openbmb/MiniCPM-o-4_5-GGUF --include MiniCPM-o-4_5-Q4_K_M.gguf --local-dir C:\Users\Andre\codes\LJB\hackthon\llamacpp\models\MiniCPM-o-4_5-gguf
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
如果下载中断需续传:
|
| 20 |
+
```cmd
|
| 21 |
+
hf download openbmb/MiniCPM-o-4_5-GGUF --include MiniCPM-o-4_5-Q4_K_M.gguf --local-dir C:\Users\Andre\codes\LJB\hackthon\llamacpp\models\MiniCPM-o-4_5-gguf --resume
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
## Step 3: 验证文件大小
|
| 25 |
+
|
| 26 |
+
```cmd
|
| 27 |
+
dir C:\Users\Andre\codes\LJB\hackthon\llamacpp\models\MiniCPM-o-4_5-gguf\MiniCPM-o-4_5-Q4_K_M.gguf
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
预期:**~4,500,000,000 - 5,500,000,000 bytes(约 4.5-5.5 GB)**
|
| 31 |
+
当前:721,420,288 bytes(约 0.7 GB)
|
| 32 |
+
|
| 33 |
+
下载完成后通知我,一起进行下一步。
|
tmp_llama_mtmd_test_guide.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# llama-mtmd-cli 本地推理测试
|
| 2 |
+
|
| 3 |
+
编译成功!`-i` 不是有效参数。以下是正确命令。
|
| 4 |
+
|
| 5 |
+
## 纯文本测试(无图片)
|
| 6 |
+
|
| 7 |
+
```cmd
|
| 8 |
+
cd C:\Users\Andre\codes\LJB\hackthon\llamacpp\llama.cpp\build\bin\Release
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
```cmd
|
| 12 |
+
llama-mtmd-cli -m C:\Users\Andre\codes\LJB\hackthon\llamacpp\models\MiniCPM-o-4_5-gguf\MiniCPM-o-4_5-Q4_K_M.gguf --mmproj C:\Users\Andre\codes\LJB\hackthon\llamacpp\models\MiniCPM-o-4_5-gguf\vision\MiniCPM-o-4_5-vision-F16.gguf -c 4096 --temp 0.7 --top-p 0.8 --top-k 100 --repeat-penalty 1.05 -p "用中文简单介绍一下你自己"
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
## 带图片测试
|
| 16 |
+
|
| 17 |
+
找一张图片(比如 `C:\Users\Andre\Pictures\test.jpg`),运行:
|
| 18 |
+
|
| 19 |
+
```cmd
|
| 20 |
+
llama-mtmd-cli -m C:\Users\Andre\codes\LJB\hackthon\llamacpp\models\MiniCPM-o-4_5-gguf\MiniCPM-o-4_5-Q4_K_M.gguf --mmproj C:\Users\Andre\codes\LJB\hackthon\llamacpp\models\MiniCPM-o-4_5-gguf\vision\MiniCPM-o-4_5-vision-F16.gguf -c 4096 --temp 0.7 --top-p 0.8 --top-k 100 --repeat-penalty 1.05 --image C:\Users\Andre\Pictures\test.jpg -p "用中文描述这张图片里的内容"
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
## 查看所有可用参数
|
| 24 |
+
|
| 25 |
+
```cmd
|
| 26 |
+
llama-mtmd-cli --help
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
> 注意:`-i` 不是有效参数。图片用 `--image` 指定,文本提示用 `-p` 指定。
|
| 30 |
+
> 首次加载模型可能需要 30-60 秒。
|
tmp_official_deploy_guide.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 基于官方教程的部署方案
|
| 2 |
+
|
| 3 |
+
来源:MiniCPM-V-Cookbook/deployment/llama.cpp/minicpm-o4_5_llamacpp_zh.md
|
| 4 |
+
|
| 5 |
+
## 关键发现
|
| 6 |
+
|
| 7 |
+
1. **MiniCPM-o-4.5 必须用 `llama-mtmd-cli`(多模态解码器)** 运行,不是普通 `llama-cli`
|
| 8 |
+
2. 正确命令行格式:
|
| 9 |
+
```bash
|
| 10 |
+
./llama-mtmd-cli \
|
| 11 |
+
-m MiniCPM-o-4_5-Q4_K_M.gguf \
|
| 12 |
+
--mmproj MiniCPM-o-4_5-vision-F16.gguf \
|
| 13 |
+
-c 4096 --temp 0.7 --top-p 0.8 --top-k 100 \
|
| 14 |
+
--repeat-penalty 1.05 \
|
| 15 |
+
--image xx.jpg \
|
| 16 |
+
-p "What is in the image?"
|
| 17 |
+
```
|
| 18 |
+
3. 需要克隆 `https://github.com/ggml-org/llama.cpp.git`(主仓库,不是 llama.cpp-omni)
|
| 19 |
+
4. llama.cpp 编译时需启用 CMake,CUDA 模式加 `-DGGML_CUDA=ON`
|
| 20 |
+
|
| 21 |
+
## 对比之前 deploy.py 的问题
|
| 22 |
+
|
| 23 |
+
| 项目 | 之前方案 | 官方方案 |
|
| 24 |
+
|------|---------|---------|
|
| 25 |
+
| 执行程序 | `llama_cpp.Llama()` Python 绑定 | `llama-mtmd-cli` / `llama-server` |
|
| 26 |
+
| mmproj 传参 | bug: 递归传全部 .gguf | `--mmproj vision-F16.gguf`(单一文件) |
|
| 27 |
+
| 推荐的 API 模式 | OpenAI SDK 包装 | `llama-server` 原生 OpenAI 兼容 API |
|
| 28 |
+
|
| 29 |
+
## 部署步骤(待下载完成)
|
| 30 |
+
|
| 31 |
+
1. 下载完整 `MiniCPM-o-4_5-Q4_K_M.gguf`(先删除损坏 721MB 版)
|
| 32 |
+
2. 克隆/更新 `ggml-org/llama.cpp`
|
| 33 |
+
3. 编译 `llama-server`(含 `llama-mtmd` 支持)
|
| 34 |
+
4. 本地运行 `llama-mtmd-cli` 验证推理
|
| 35 |
+
5. 修改 Modal 方案:用 `llama-server` 方式部署
|
tmp_upload_and_test_guide.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 下一步操作指南
|
| 2 |
+
|
| 3 |
+
## 📤 1. 上传模型到 Modal Volume
|
| 4 |
+
|
| 5 |
+
在**新开一个终端**(不要关当前的),运行:
|
| 6 |
+
|
| 7 |
+
```cmd
|
| 8 |
+
modal volume put minicpm-o-4_5-models C:\Users\Andre\codes\LJB\hackthon\llamacpp\models\MiniCPM-o-4_5-gguf /MiniCPM-o-4_5-gguf
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
上传完成后验证:
|
| 12 |
+
|
| 13 |
+
```cmd
|
| 14 |
+
modal volume ls minicpm-o-4_5-models /MiniCPM-o-4_5-gguf
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
预期输出:
|
| 18 |
+
```
|
| 19 |
+
MiniCPM-o-4_5-Q4_K_M.gguf
|
| 20 |
+
vision/
|
| 21 |
+
vision/MiniCPM-o-4_5-vision-F16.gguf
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## 🖥️ 2. 本地检查(在当前终端执行)
|
| 27 |
+
|
| 28 |
+
### 2a. 检查 vision 文件是否存在
|
| 29 |
+
|
| 30 |
+
```cmd
|
| 31 |
+
dir C:\Users\Andre\codes\LJB\hackthon\llamacpp\models\MiniCPM-o-4_5-gguf\vision
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
### 2b. 检查 llama.cpp 是否已编译
|
| 35 |
+
|
| 36 |
+
```cmd
|
| 37 |
+
dir C:\Users\Andre\codes\LJB\hackthon\llamacpp\llama.cpp\build\bin\llama-mtmd-cli.exe
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
---
|
| 41 |
+
|
| 42 |
+
## 告诉我结果
|
| 43 |
+
|
| 44 |
+
把上面 2a 和 2b 的运行结果发给我,我来判断下一步怎么做。
|
tmp_volume_cleanup_guide.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Modal Volume 清理指南
|
| 2 |
+
|
| 3 |
+
问题:Volume 里有旧的损坏文件,需要先清空再上传。
|
| 4 |
+
|
| 5 |
+
## 方案一:删除旧文件 + 覆盖上传
|
| 6 |
+
|
| 7 |
+
先删掉 Volume 里的旧内容,再上传:
|
| 8 |
+
|
| 9 |
+
```cmd
|
| 10 |
+
modal volume rm minicpm-o-4_5-models /MiniCPM-o-4_5-gguf -r
|
| 11 |
+
```
|
| 12 |
+
|
| 13 |
+
然后再上传:
|
| 14 |
+
|
| 15 |
+
```cmd
|
| 16 |
+
modal volume put minicpm-o-4_5-models C:\Users\Andre\codes\LJB\hackthon\llamacpp\models\MiniCPM-o-4_5-gguf /MiniCPM-o-4_5-gguf
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
运行顺序:先第一行命令,再第二行。
|