Instructions to use ziren28/wenwu2-models with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use ziren28/wenwu2-models with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf ziren28/wenwu2-models:Q4_K_M # Run inference directly in the terminal: llama cli -hf ziren28/wenwu2-models:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf ziren28/wenwu2-models:Q4_K_M # Run inference directly in the terminal: llama cli -hf ziren28/wenwu2-models:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf ziren28/wenwu2-models:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf ziren28/wenwu2-models:Q4_K_M
Use Docker
docker model run hf.co/ziren28/wenwu2-models:Q4_K_M
- Llama new
- LM Studio
- Jan
- Ollama
How to use ziren28/wenwu2-models with Ollama:
ollama run hf.co/ziren28/wenwu2-models:Q4_K_M
- Unsloth Desktop
- Pi
How to use ziren28/wenwu2-models with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ziren28/wenwu2-models:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "ziren28/wenwu2-models:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use ziren28/wenwu2-models with Docker Model Runner:
docker model run hf.co/ziren28/wenwu2-models:Q4_K_M
- Lemonade
How to use ziren28/wenwu2-models with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull ziren28/wenwu2-models:Q4_K_M
Run and chat with the model
lemonade run user.wenwu2-models-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use ziren28/wenwu2-models with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ziren28/wenwu2-models:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default ziren28/wenwu2-models:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use ziren28/wenwu2-models with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ziren28/wenwu2-models:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "ziren28/wenwu2-models:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Download deploy/molab_deploy.py from ziren28/wenwu2-models: direct link, hf CLI and curl.
- Browser
- Download file 12.4 kB
-
https://huggingface.co/ziren28/wenwu2-models/resolve/main/deploy/molab_deploy.py
- Command line
-
hf download hf://ziren28/wenwu2-models/deploy/molab_deploy.py
-
curl -L -o molab_deploy.py https://huggingface.co/ziren28/wenwu2-models/resolve/main/deploy/molab_deploy.py
12.4 kB
| #!/usr/bin/env python3 | |
| """molab 一键部署:拿到 molab 链接 + 秘钥 -> YZ 768 工作流环境就绪 -> 自动接入台湾网关(pull 模式 A)。 | |
| 用法: | |
| python3 molab_deploy.py --url https://sb-xxxx.sb.molab.run/ --token-file tok.txt \ | |
| [--name molab_xxxx] [--gateway http://127.0.0.1:18100] [--admin-key-file ~/h3gw_data/api_key] [--no-attach] | |
| 依赖:仅 Python3 标准库。环境与模型全部从 HF 公共仓库 ziren28/wenwu2-models 并行下载 | |
| (失败时若 molab 上已有 rclone 配置则回退 Google Drive molabgd:molab/)。已存在且大小正确的文件跳过。 | |
| """ | |
| import argparse, base64, json, os, re, sys, time, urllib.request, urllib.error | |
| from pathlib import Path | |
| HF = "https://huggingface.co/ziren28/wenwu2-models/resolve/main/" | |
| ENV_DIR = "/marimo/wenwu_headless_20261114" | |
| MODELS = ENV_DIR + "/sources/ComfyUI/models" | |
| ENV_TAR = ("env/wenwu_env_20261119.tar", 7694315520, "molab/env/wenwu_env_20261119.tar") | |
| # (HF 路径 = models/ 下相对路径, 字节数, Drive 备份路径) | |
| MODEL_FILES = [ | |
| ("diffusion_models/minimax_h3_hybrid_fl2va_ref2va_b25-49-int8.safetensors", 20967647456, | |
| "molab/models/diffusion_models_fixed/minimax_h3_hybrid_fl2va_ref2va_b25-49-int8.safetensors"), | |
| ("text_encoders/qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors", 15687142551, | |
| "molab/models/text_encoders/qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors"), | |
| ("vae/minimax_h3_audio_vae_fp32.safetensors", 605254808, "molab/models/vae/minimax_h3_audio_vae_fp32.safetensors"), | |
| ("vae/minimax_h3_video_vae_int8_convrot.safetensors", 2811065184, | |
| "molab/models/vae/minimax_h3_video_vae_int8_convrot.safetensors"), | |
| ("loras/MysticXXX_MMH3-V1.safetensors", 596451528, "molab/models/loras/MysticXXX_MMH3-V1.safetensors"), | |
| ("loras/minimax_h3_dmad_full_dareties_v4_step600_comfy_fro.safetensors", 956743688, | |
| "molab/models/loras/minimax_h3_dmad_full_dareties_v4_step600_comfy_fro.safetensors"), | |
| ("latent_upscale_models/h3_upscaler_lms_v0.1.safetensors", 690593048, | |
| "molab/models/latent_upscale_models/h3_upscaler_lms_v0.1.safetensors"), | |
| ] | |
| def log(*a): | |
| print(time.strftime("%H:%M:%S"), *a, flush=True) | |
| class Molab: | |
| def __init__(self, url, token): | |
| self.url, self.token, self.sid = url.rstrip("/"), token, None | |
| def _req(self, method, path, body=None, extra=None, timeout=60): | |
| h = {"Authorization": "Bearer " + self.token, "User-Agent": "molab-deploy/1.0"} | |
| h.update(extra or {}) | |
| return urllib.request.urlopen(urllib.request.Request(self.url + path, data=body, method=method, headers=h), | |
| timeout=timeout) | |
| def exec(self, code, timeout=120): | |
| for attempt in range(4): | |
| try: | |
| if not self.sid: | |
| with self._req("GET", "/api/sessions", timeout=30) as r: | |
| ss = json.loads(r.read() or b"{}") | |
| if not ss: | |
| raise ConnectionError("molab 没有活动的 notebook 会话:请先在浏览器打开一次该 molab 链接") | |
| self.sid = next(iter(ss)) | |
| with self._req("POST", "/api/kernel/execute", json.dumps({"code": code}).encode(), | |
| {"Content-Type": "application/json", "Marimo-Session-Id": self.sid}, timeout) as r: | |
| out, err, ev, done = [], [], "", None | |
| for raw in r: | |
| line = raw.decode("utf-8", "replace").rstrip("\r\n") | |
| if line.startswith("event:"): | |
| ev = line[6:].strip() | |
| elif line.startswith("data:"): | |
| d = json.loads(line[5:].strip() or "{}") | |
| if ev == "stdout": | |
| out.append(d.get("data", "")) | |
| elif ev == "stderr": | |
| err.append(d.get("data", "")) | |
| elif ev == "done": | |
| done = d | |
| break | |
| if done is None: | |
| raise ConnectionError("exec stream ended early") | |
| if done.get("success") is False: | |
| o = done.get("output") or {} | |
| raise RuntimeError("molab exec error: " + (str(o.get("data") or "") + "".join(err))[-600:]) | |
| return "".join(out) | |
| except urllib.error.HTTPError as e: | |
| if e.code in (401, 403): | |
| raise SystemExit(f"秘钥无效或无权限 (HTTP {e.code})") | |
| self.sid = None | |
| if attempt == 3: | |
| raise | |
| except (urllib.error.URLError, ConnectionError, TimeoutError, OSError) as e: | |
| if "没有活动" in str(e) or attempt == 3: | |
| raise | |
| self.sid = None | |
| time.sleep(5 * (attempt + 1)) | |
| def sh(self, cmd, timeout=120): | |
| code = ("import subprocess\nr=subprocess.run(%r,shell=True,capture_output=True,text=True)\n" | |
| "print(r.stdout[-6000:]+r.stderr[-2000:])" % cmd) | |
| return self.exec(code, timeout) | |
| def setup_script(): | |
| lines = [ | |
| "#!/bin/bash", | |
| f"B={HF}; E={ENV_DIR}; M={MODELS}; S=/marimo/deploy", | |
| "mkdir -p $S; : > $S/result", | |
| "sz(){ stat -c%s \"$1\" 2>/dev/null || echo 0; }", | |
| "fetch(){ rel=$1; dst=$2; size=$3; gd=$4", | |
| " [ \"$(sz $dst)\" = \"$size\" ] && { echo \"OK $rel cached\" >> $S/result; return 0; }", | |
| " mkdir -p \"$(dirname $dst)\"", | |
| " for i in 1 2 3 4; do", | |
| " [ \"$(sz $dst.part)\" -gt \"$size\" ] && rm -f $dst.part", | |
| " curl -sSL -C - --retry 5 --retry-delay 5 --connect-timeout 30 -o $dst.part \"$B$rel\"", | |
| " [ \"$(sz $dst.part)\" = \"$size\" ] && { mv $dst.part $dst; echo \"OK $rel hf\" >> $S/result; return 0; }", | |
| " sleep 10; done", | |
| " if command -v rclone >/dev/null && [ -f ~/.config/rclone/rclone.conf ]; then", | |
| " rclone copyto molabgd:$gd $dst.part --drive-chunk-size 128M && [ \"$(sz $dst.part)\" = \"$size\" ] && { mv $dst.part $dst; echo \"OK $rel gdrive\" >> $S/result; return 0; }", | |
| " fi", | |
| " echo \"FAIL $rel\" >> $S/result; return 1; }", | |
| "envjob(){", | |
| " if [ -x $E/.venv/bin/python ] && [ -f $E/run_job.py ] && [ -f $E/headless_engine.py ]; then echo 'OK env cached' >> $S/result; return 0; fi", | |
| f" fetch {ENV_TAR[0]} $S/env.tar {ENV_TAR[1]} {ENV_TAR[2]} || return 1", | |
| " tar xf $S/env.tar -C /marimo && rm -f $S/env.tar && echo 'OK env extracted' >> $S/result || { echo 'FAIL env untar' >> $S/result; return 1; }", | |
| "}", | |
| "pids=()", | |
| "envjob & pids+=($!)", | |
| ] | |
| for rel, size, gd in MODEL_FILES: | |
| lines.append(f"fetch {rel} $M/{rel} {size} {gd} & pids+=($!)") | |
| lines += [ | |
| "rc=0; for p in ${pids[@]}; do wait $p || rc=1; done", | |
| "if [ $rc = 0 ]; then", | |
| " $E/.venv/bin/python -c 'import torch;assert torch.cuda.is_available();print(\"torch\",torch.__version__,torch.cuda.get_device_name(0))' >> $S/result 2>&1 || rc=1", | |
| "fi", | |
| "[ $rc = 0 ] && echo DONE > $S/state || echo FAIL > $S/state", | |
| ] | |
| return "\n".join(lines) + "\n" | |
| def progress(mx): | |
| out = mx.sh("cat /marimo/deploy/state 2>/dev/null; echo ---; cat /marimo/deploy/result 2>/dev/null; echo ---; " | |
| f"find /marimo/deploy {MODELS} -name '*.part' -printf '%s\\n' 2>/dev/null | awk '{{s+=$1}} END {{print s+0}}'") | |
| parts = out.split("---") | |
| return parts[0].strip(), parts[1].strip() if len(parts) > 1 else "", int((parts[2].strip() or "0").split()[0]) if len(parts) > 2 else 0 | |
| def gw_call(gw, key, method, path, obj=None, timeout=60): | |
| data = json.dumps(obj).encode() if obj is not None else None | |
| req = urllib.request.Request(gw.rstrip("/") + path, data=data, method=method, | |
| headers={"Authorization": "Bearer " + key, "Content-Type": "application/json"}) | |
| with urllib.request.urlopen(req, timeout=timeout) as r: | |
| return json.loads(r.read() or b"{}") | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--url", required=True) | |
| ap.add_argument("--token") | |
| ap.add_argument("--token-file") | |
| ap.add_argument("--rm-token-file", action="store_true", help="读取后删除秘钥文件") | |
| ap.add_argument("--name") | |
| ap.add_argument("--gateway", default="https://h3.zirun.me") | |
| ap.add_argument("--admin-key-file", default=str(Path.home() / "h3gw_data/api_key")) | |
| ap.add_argument("--no-attach", action="store_true") | |
| ap.add_argument("--timeout-min", type=int, default=90) | |
| a = ap.parse_args() | |
| token = (a.token or Path(a.token_file).read_text()).strip() | |
| if a.token_file and a.rm_token_file: | |
| Path(a.token_file).unlink(missing_ok=True) | |
| m = re.search(r"sb-([0-9a-f]{4})", a.url) | |
| name = a.name or ("molab_" + (m.group(1) if m else str(int(time.time()))[-4:])) | |
| t0 = time.time() | |
| mx = Molab(a.url, token) | |
| log(f"[1/5] 连接 molab {name} ...") | |
| info = mx.sh("nvidia-smi --query-gpu=name,memory.total --format=csv,noheader; df -h /marimo | tail -1", 60) | |
| log(" GPU/磁盘:", " | ".join(info.strip().splitlines())) | |
| log("[2/5] 启动并行下载(运行环境 7.7G + 7 个模型 42G)...") | |
| sc = base64.b64encode(setup_script().encode()).decode() | |
| mx.exec("import base64,subprocess,os\nos.makedirs('/marimo/deploy',exist_ok=True)\n" | |
| "open('/marimo/deploy/setup.sh','wb').write(base64.b64decode(%r))\n" | |
| "open('/marimo/deploy/state','w').write('RUNNING')\n" | |
| "subprocess.Popen(['bash','-c','bash /marimo/deploy/setup.sh > /marimo/deploy/setup.log 2>&1'],start_new_session=True)\n" | |
| "print('started')" % sc) | |
| total = ENV_TAR[1] + sum(s for _, s, _ in MODEL_FILES) | |
| last = "" | |
| while True: | |
| time.sleep(20) | |
| try: | |
| state, res, part = progress(mx) | |
| except Exception as e: | |
| log(" 进度查询失败,重试:", str(e)[:120]) | |
| continue | |
| done_n = len([l for l in res.splitlines() if l.startswith("OK")]) | |
| line = f" {state} 已完成 {done_n}/8 项,进行中 {part / 1e9:.1f}G,用时 {int(time.time() - t0)}s" | |
| if line != last: | |
| log(line) | |
| last = line | |
| if state in ("DONE", "FAIL"): | |
| break | |
| if time.time() - t0 > a.timeout_min * 60: | |
| raise SystemExit("下载超时") | |
| log(" 结果:\n " + res.replace("\n", "\n ")) | |
| if state != "DONE": | |
| log(mx.sh("tail -30 /marimo/deploy/setup.log")) | |
| raise SystemExit("环境/模型准备失败") | |
| log("[3/5] 安装网关 agent ...") | |
| here = Path(__file__).resolve().parent | |
| ag = here / "h3gw_molab" / "h3agent.py" | |
| src = ag.read_bytes() if ag.exists() else urllib.request.urlopen(HF + "deploy/h3gw_molab/h3agent.py", timeout=60).read() | |
| mx.exec("import base64,os\nos.makedirs('/marimo/h3gw_molab',exist_ok=True)\n" | |
| "open('/marimo/h3gw_molab/h3agent.py','wb').write(base64.b64decode(%r))\nprint('ok')" | |
| % base64.b64encode(src).decode()) | |
| st = mx.exec("import sys,json,importlib\nsys.path.insert(0,'/marimo/h3gw_molab')\nimport h3agent\n" | |
| "importlib.reload(h3agent)\nprint('H3R:'+json.dumps(h3agent.stats()))") | |
| log(" agent stats:", (re.search(r"H3R:(.*)", st) or [None, st[-200:]])[1][:300]) | |
| if a.no_attach: | |
| log(f"DEPLOY_READY 环境就绪(由网关接入),用时 {int(time.time() - t0)}s") | |
| return | |
| log(f"[4/5] 接入网关 {a.gateway} ...") | |
| key = Path(a.admin_key_file).expanduser().read_text().strip() | |
| r = gw_call(a.gateway, key, "POST", "/v1/admin/molab/attach", {"name": name, "url": a.url, "token": token}) | |
| log(" ", json.dumps(r, ensure_ascii=False)) | |
| log("[5/5] 等待 pull 模式(A) 心跳 ...") | |
| for _ in range(36): | |
| time.sleep(10) | |
| ws = gw_call(a.gateway, key, "GET", "/v1/status").get("workers", []) | |
| w = next((w for w in ws if w.get("name") == name), None) | |
| if w and w.get("pulling"): | |
| log(f"DEPLOY_READY ✅ {name} 已上线:state={w.get('state')} pulling=True,总用时 {int(time.time() - t0)}s") | |
| return | |
| raise SystemExit("已接入但 3 分钟内未见 pull 心跳,请查看网关日志") | |
| if __name__ == "__main__": | |
| main() | |