MiniMax H3 小白部署教程:RTX 4090 24GB 照着做就能成功

这是 上一篇 H3 部署实录 的「答案卷」版本:实录讲踩坑过程,这篇只讲照着做就能成功的路径。每一步都经过实测(2026-11-19,Ubuntu 22.04 + RTX 4090 24GB + 驱动 550.142)。
每步末尾有【验证】——做完必须看到期望输出再进行下一步,看到的不一样就停下排查。
预计总耗时:2~3 小时(主要是下载 53.5GB 模型)。


第 0 步:前置检查(不满足就别往下走)

SSH 登录服务器后,逐条执行:

1
nvidia-smi | grep "CUDA Version"

【验证】必须显示 CUDA Version: 12.4 或更高。

  • 低于 12.4(如 12.1/12.0)→ 此教程不适用,H3 在旧驱动上无法运行(实测结论,别浪费时间)
  • 没有 GPU → 不适用
1
df -h /

【验证】Avail(可用)≥ 60GB。不够就先清理(大文件常见于 ~/.ollama、~/.cache)。

1
free -g

【验证】内存 ≥ 28GB(模型要驻留内存)。


第 1 步:装基础工具 + 建目录

1
2
3
sudo apt-get update
sudo apt-get install -y aria2 python3.10-venv python3.10-dev
mkdir -p ~/comfy/ComfyUI/models/{diffusion_models,text_encoders,vae,loras} ~/comfy/logs

python3.10-dev 别漏——后面 triton 编译需要 Python.h,漏了会在第 4 步报 fatal error: Python.h: No such file or directory。

【验证】

1
aria2c --version | head -1 && ls ~/comfy/ComfyUI/models/

应显示 aria2 版本号 + 四个模型目录。


第 2 步:下载模型(53.5GB,约 1.5 小时)

把下面整段保存为 ~/comfy/download_models.sh:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
BASE="https://modelscope.cn/models/Comfy-Org/MiniMax-H3/resolve/master"
M="$HOME/comfy/ComfyUI/models"
LOG="$HOME/comfy/logs/download.log"

dl() {
local dir="$1" file="$2"
aria2c -x16 -s16 -c --dir="$M/$dir" --out="$file" "$BASE/$dir/$file" >> "$LOG" 2>&1
echo "[done] $file" >> "$LOG"
}

# 先小后大
dl vae minimax_h3_audio_vae_fp32.safetensors
dl vae minimax_h3_video_vae_int8_convrot.safetensors
dl loras minimax_h3_ref2v_turbo_4step_v0.1_comfyui_bf16.safetensors
dl diffusion_models minimax_h3_ref2va_pruned_int8_convrot.safetensors
dl text_encoders qwen3vl_32b_minimax_h3_int8_convrot.safetensors

echo "[ALL-DONE]" >> "$LOG"

运行:

1
bash ~/comfy/download_models.sh

可以断开 SSH,它自己跑。随时用这个命令看进度:

1
tail -5 ~/comfy/logs/download.log

【验证】日志出现 [ALL-DONE],且五个文件大小完全一致(字节级):

1
2
3
4
ls -la ~/comfy/ComfyUI/models/diffusion_models/*.safetensors \
~/comfy/ComfyUI/models/text_encoders/*.safetensors \
~/comfy/ComfyUI/models/vae/*.safetensors \
~/comfy/ComfyUI/models/loras/*.safetensors
文件 必须是这个字节数
diffusion_models/minimax_h3_ref2va_pruned_int8_convrot.safetensors 20970379616
text_encoders/qwen3vl_32b_minimax_h3_int8_convrot.safetensors 27141342152
vae/minimax_h3_video_vae_int8_convrot.safetensors 2811065184
vae/minimax_h3_audio_vae_fp32.safetensors 605254808
loras/minimax_h3_ref2v_turbo_4step_v0.1_comfyui_bf16.safetensors 1956193000

⚠️ 别下载 fp8_scaled 版的 diffusion——实测 24GB 显存加载时必爆(stochastic_rounding 转换超显存),int8 是唯一可用格式。


第 3 步:获取 ComfyUI 代码(必须 master 分支)

⚠️ 不要用 v0.3.38 或任何旧 tag——H3 节点(MiniMaxH3ReferenceToVideo 等)只在 master 分支,旧版会报 node does not exist。

服务器上直接试(国内网络 gh-proxy 有时通):

1
2
3
curl -sL -o /tmp/comfyui-master.tar.gz \
"https://gh-proxy.com/https://github.com/comfyanonymous/ComfyUI/archive/refs/heads/master.tar.gz"
tar -tzf /tmp/comfyui-master.tar.gz >/dev/null 2>&1 && echo OK || echo BROKEN

【验证】显示 OK。如果是 BROKEN 或超时,换你自己的电脑下载这个 URL,然后传上去:

1
2
# 在自己电脑上(scp 传大文件会断,用 rsync)
rsync -P -e "ssh" comfyui-master.tar.gz ubuntu@<服务器IP>:/tmp/

解压:

1
tar -xzf /tmp/comfyui-master.tar.gz --strip-components=1 -C ~/comfy/ComfyUI/

【验证】

1
ls ~/comfy/ComfyUI/comfy_extras/nodes_minimax_h3.py

文件存在 = H3 节点代码就位。


第 4 步:Python 环境(torch cu124)

1
2
3
cd ~/comfy/ComfyUI
python3 -m venv venv
source venv/bin/activate

按顺序执行 4 条安装命令(顺序有讲究,别合并):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 1) torch 的纯 Python 依赖(清华源)
pip install filelock typing-extensions sympy networkx jinja2 fsspec \
-i https://pypi.tuna.tsinghua.edu.cn/simple

# 2) torch 本体(阿里镜像;--no-index 防止它去连不上的官方源)
pip install torch==2.6.0+cu124 torchvision==0.21.0+cu124 torchaudio==2.6.0+cu124 \
-f https://mirrors.aliyun.com/pytorch-wheels/cu124/ --no-index --no-deps

# 3) CUDA 运行库(--no-deps 跳过的部分,cu124 版本号)
pip install nvidia-cuda-nvrtc-cu12==12.4.127 nvidia-cuda-runtime-cu12==12.4.127 \
nvidia-cuda-cupti-cu12==12.4.127 nvidia-cudnn-cu12==9.1.0.70 \
nvidia-cublas-cu12==12.4.5.8 nvidia-cufft-cu12==11.2.1.3 \
nvidia-curand-cu12==10.3.5.147 nvidia-cusolver-cu12==11.6.1.9 \
nvidia-cusparse-cu12==12.3.1.170 nvidia-nccl-cu12==2.21.5 \
nvidia-nvtx-cu12==12.4.127 nvidia-nvjitlink-cu12==12.4.127 triton==3.2.0 \
-i https://pypi.tuna.tsinghua.edu.cn/simple

# 4) ComfyUI 其余依赖(剔除清华源缺子包的 templates,不影响功能)
grep -v comfyui-workflow-templates requirements.txt > /tmp/req2.txt
pip install -r /tmp/req2.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

【验证】

1
python -c "import torch; print(torch.__version__, torch.cuda.is_available())"

必须输出:2.6.0+cu124 True


第 5 步:三个关键补丁(缺一不可,都是实测踩出来的)

补丁 ① comfy_kitchen 类型签名(torch 2.6 不认 list[int])

1
2
3
4
5
6
7
8
9
10
cd ~/comfy/ComfyUI
SP=venv/lib/python3.10/site-packages/comfy_kitchen
find "$SP" -name "*.py" | while read -r f; do
if grep -qE ": list\[(int|bool|float)\]" "$f"; then
sed -i -E 's/: list\[(int|bool|float)\]/: Sequence[\1]/g' "$f"
head -5 "$f" | grep -q "from typing import Sequence" || \
sed -i '1i from typing import Sequence' "$f"
echo "patched: ${f#$SP/}"
fi
done

【验证】

1
python -c "import comfy_kitchen; print('CK-OK')"

输出 CK-OK。如果报 Python.h not found → 回第 1 步装 python3.10-dev;如果报 libcuda 链接错误 → 执行:

1
2
ls /usr/lib/x86_64-linux-gnu/libcuda.so.550* && \
sudo ln -sf /usr/lib/x86_64-linux-gnu/libcuda.so.550.142 /usr/lib/x86_64-linux-gnu/libcuda.so

补丁 ② 禁用 sage attention(550 驱动带不动它的 CUDA kernel)

不打的话,生成时报 detect_k_anchor kernel launch failed: CUDA driver version is insufficient。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
cd ~/comfy/ComfyUI
# 改 1:ComfyUI 的缓存常量(注意:改函数没用,必须改这个模块级常量)
python - <<'EOF'
p = "comfy/ldm/modules/attention.py"
src = open(p).read()
old = "COMFY_KITCHEN_INT8_ATTENTION_IS_AVAILABLE = comfy_kitchen.int8_attention_is_available()"
new = "COMFY_KITCHEN_INT8_ATTENTION_IS_AVAILABLE = False # driver too old for int8 attention cuda kernel"
assert old in src, "pattern not found!"
open(p, "w").write(src.replace(old, new))
print("patch 2a done")
EOF

# 改 2:comfy_kitchen 的 is_available
python - <<'EOF'
p = "venv/lib/python3.10/site-packages/comfy_kitchen/sage_attention.py"
src = open(p).read()
old = " return capability >= _NATIVE_MINIMUM_CAPABILITY and _cuda_backend._EXT_AVAILABLE"
new = " return False # FORCE_DISABLED: driver too old"
assert old in src, "pattern not found!"
open(p, "w").write(src.replace(old, new))
print("patch 2b done")
EOF

【验证】

1
python -c "import comfy_kitchen; print('int8_attn:', comfy_kitchen.int8_attention_is_available())"

必须输出 int8_attn: False(False 才对——禁用了有问题的 CUDA kernel,走稳定的 eager 路径)。

补丁 ③ 无需操作,已包含在第 1 步(python3.10-dev)和补丁 ① 的验证里


第 6 步:启动(必须 –novram)

⚠️ --novram 不能省:24GB 显存装不下 21GB diffusion + 27GB 文本编码器同时驻留。
novram 模式 = 模型驻留内存,GPU 按层取权重。实测单条视频约 5-6 分钟。

1
2
3
4
cd ~/comfy/ComfyUI && source venv/bin/activate
nohup python main.py --listen 0.0.0.0 --novram > ~/comfy/logs/comfyui.log 2>&1 &
sleep 30
curl -s http://127.0.0.1:8188/system_stats | head -c 200

【验证】返回 JSON(含 comfyui_version 和 GPU 信息)。

(推荐)systemd 开机自启

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
sudo tee /etc/systemd/system/comfyui.service > /dev/null <<'EOF'
[Unit]
Description=ComfyUI (MiniMax H3)
After=network.target

[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/comfy/ComfyUI
ExecStart=/home/ubuntu/comfy/ComfyUI/venv/bin/python main.py --listen 0.0.0.0 --novram
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload && sudo systemctl enable comfyui

注意 ExecStart 里的 --novram。


第 7 步:跑通第一条视频

在你自己的电脑上建隧道(云服务器安全组通常没放行 8188):

1
ssh -N -f -L 8188:localhost:8188 ubuntu@<服务器IP>

浏览器开 http://localhost:8188(如果 403,改用 http://127.0.0.1:8188)。

用 API 提交测试(工作流要点):

1
2
3
4
5
6
7
UNETLoader(minimax_h3_ref2va_pruned_int8_convrot.safetensors)
→ LoraLoader(minimax_h3_ref2v_turbo_4step..., 同时接 clip)
CLIPLoader(qwen3vl_32b..., type=minimax, device=cpu) ← device=cpu 必须设!
→ LoraLoader(clip 通道)
→ MiniMaxH3ReferenceToVideo(768×768, 39帧, ref_image_size=max)
→ KSampler(steps=4, cfg=1.0, euler+simple)
→ VAEDecode → CreateVideo(fps=24) → SaveVideo

⚠️ **CLIPLoader 的 device 必须是 cpu**——不设的话文本编码器和 diffusion 争显存,必 OOM。

⚠️ 别用默认的 1344×768——MLP buffer 会大很多,768×768 是安全值。

完整可运行的提交脚本(Python,在本机跑):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# submit_test.py —— 提交 + 自动轮询
import json, time, urllib.request, uuid

SERVER = "http://localhost:8188"
wf = {
"3": {"class_type": "UNETLoader",
"inputs": {"unet_name": "minimax_h3_ref2va_pruned_int8_convrot.safetensors", "weight_dtype": "default"}},
"4": {"class_type": "LoraLoader",
"inputs": {"lora_name": "minimax_h3_ref2v_turbo_4step_v0.1_comfyui_bf16.safetensors",
"strength_model": 1.0, "strength_clip": 1.0,
"model": ["3", 0], "clip": ["5", 0]}},
"5": {"class_type": "CLIPLoader",
"inputs": {"clip_name": "qwen3vl_32b_minimax_h3_int8_convrot.safetensors",
"type": "minimax", "device": "cpu"}},
"6": {"class_type": "VAELoader", "inputs": {"vae_name": "minimax_h3_video_vae_int8_convrot.safetensors"}},
"7": {"class_type": "VAELoader", "inputs": {"vae_name": "minimax_h3_audio_vae_fp32.safetensors"}},
"8": {"class_type": "MiniMaxH3ReferenceToVideo",
"inputs": {"clip": ["4", 1], "vae": ["6", 0], "audio_vae": ["7", 0],
"prompt": "A cute cartoon cow waving on the Great Wall",
"width": 768, "height": 768, "length": 39,
"ref_image_size": "match"}},
"10": {"class_type": "KSampler",
"inputs": {"model": ["4", 0], "positive": ["8", 0], "negative": ["8", 0],
"latent_image": ["8", 1], "seed": 42, "steps": 4, "cfg": 1.0,
"sampler_name": "euler", "scheduler": "simple", "denoise": 1.0}},
"11": {"class_type": "VAEDecode", "inputs": {"samples": ["10", 0], "vae": ["6", 0]}},
"12": {"class_type": "CreateVideo", "inputs": {"images": ["11", 0], "fps": 24.0}},
"13": {"class_type": "SaveVideo",
"inputs": {"video": ["12", 0], "filename_prefix": "h3_test", "format": "auto"}},
}

data = json.dumps({"prompt": wf, "client_id": "test"}).encode()
req = urllib.request.Request(f"{SERVER}/prompt", data=data,
headers={"Content-Type": "application/json"})
pid = json.loads(urllib.request.urlopen(req, timeout=30).read())["prompt_id"]
print("submitted:", pid)

for i in range(60):
time.sleep(10)
h = json.loads(urllib.request.urlopen(f"{SERVER}/history/{pid}", timeout=10).read())
if h:
st = h[pid]["status"]
if st.get("completed"):
print("✅ 完成!输出在服务器 ~/comfy/ComfyUI/output/")
break
for msg in st.get("messages", []):
if msg[0] == "execution_error":
print("❌", str(msg[1].get("exception_message", ""))[:200]); break
else:
print(f"[{i*10}s] 执行中...")

【验证】脚本输出 ✅ 完成,服务器 ~/comfy/ComfyUI/output/ 出现 mp4 文件。


报错速查表(实测踩过的坑)

报错关键词 原因 解法
node MiniMaxH3ReferenceToVideo does not exist ComfyUI 版本太旧 用 master 分支(第 3 步)
Parameter stride has unsupported type list[int] torch 2.6 类型签名 补丁 ①
detect_k_anchor kernel launch failed 550 驱动带不动 sage attention 补丁 ②
Python.h: No such file or directory 缺 Python 开发头文件 apt install python3.10-dev
cannot find -lcuda libcuda.so 悬空软链 第 5 步补丁 ① 验证里的 ln -sf
Allocation on device (加载模型时) 显存装不下双模型 确认 --novram + CLIPLoader device=cpu
Allocation on device (fp8 模型) fp8 转换超显存 换 int8 diffusion(别用 fp8)
pip 装 torch 只有 KB/s pytorch.org 被限速 用第 4 步的阿里镜像命令
GitHub 下载超时 网络不通 gh-proxy 或本机中转(第 3 步)
浏览器 403 ComfyUI 防 CSRF 中间件 改用 http://127.0.0.1:8188
隧道 POST 大文件 502 隧道不稳定 脚本直接放服务器上跑,访问 127.0.0.1

日常运维速查

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 重启服务
sudo systemctl restart comfyui # 或手动:cd ~/comfy/ComfyUI && source venv/bin/activate && \
# nohup python main.py --listen 0.0.0.0 --novram > ~/comfy/logs/comfyui.log 2>&1 &

# 看日志
tail -f ~/comfy/logs/comfyui.log

# 看显存/内存/磁盘
nvidia-smi; free -g; df -h /

# 清理生成产物
ls ~/comfy/ComfyUI/output/

# 下载生成的视频到自己电脑
scp 'ubuntu@<服务器IP>:~/comfy/ComfyUI/output/*.mp4' ./

附:为什么是这套组合(原理速览)

  • 驱动 550 → CUDA 12.4 → torch 2.6.0+cu124:驱动决定 CUDA 上限,旧驱动(525/CUDA 12.1)上 int8 模型会被展开成 bf16,24GB 必爆,无解
  • int8 而非 fp8:fp8 加载时的 stochastic_rounding 转换需要大块临时显存,24GB 装不下;int8 走 dequantize 路径可用
  • –novram + TE 放 CPU:21GB diffusion + 27GB TE 无法同时进 24GB 显存;novram 让模型驻留 31GB 内存,TE 编码(只发生一次)放 CPU
  • turbo LoRA 4 步:默认 20 步,turbo 降到 4 步,速度提升 5 倍,质量略降(表情包场景可接受)
  • 768×768 / 39 帧:开源版原生分辨率;帧数按 17k+5 网格(39≈1.6 秒),再大 MLP buffer 会吃显存