> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-zh/shi-pin-sheng-cheng/mochi-1.md).

# Mochi-1 视频

**Mochi-1** 是 Genmo 的开源 100 亿参数视频生成模型，可输出 848×480 @ 30fps，具有符合物理规律的真实运动。它采用非对称扩散 Transformer（AsymmDiT）架构，在运动保真度方面位列开源视频模型中的前列。将其部署在 Clore.ai 的 GPU 云上，即可用仅为商业 API 一小部分的成本生成专业级视频。

***

## 什么是 Mochi-1？

Mochi-1 是一个 **100 亿参数** 视频扩散模型，经过训练可生成具有以下特性的影片：

* 平滑、符合物理规律的运动
* 高时间一致性
* 对提示词的强遵循性
* 848×480 分辨率，30 fps

它采用 **非对称扩散 Transformer** （AsymmDiT）架构——视频和文本使用不同的编码器深度——从而实现可扩展的高效推理。模型权重以 Genmo 开源许可证发布，可免费用于研究和商业用途。

**模型亮点：**

* 100 亿参数
* 原生输出 848×480 @ 30 fps
* 高运动保真度（在社区基准测试中排名靠前）
* 可在 Hugging Face 上使用，并集成 diffusers
* 用于便捷交互的 Gradio 演示界面

***

## 前提条件

| 要求     | 最低       | 推荐          |
| ------ | -------- | ----------- |
| GPU 显存 | 24 GB    | 40–80 GB    |
| GPU    | RTX 4090 | A100 / H100 |
| 内存     | 32 GB    | 64 GB       |
| 存储     | 60 GB    | 100 GB      |
| CUDA   | 12.8+    | 12.8+       |

{% hint style="warning" %}
Mochi-1 是一个大型模型（fp8 约 40 GB / bf16 约 80 GB）。单张 RTX 4090（24 GB）可在量化后运行。要获得完整质量，建议使用 A100 40 GB 或更高配置。支持多 GPU 配置。
{% endhint %}

***

## 步骤 1——在 Clore.ai 上租用 GPU

1. 前往 [clore.ai](https://clore.ai) 并登录。
2. 点击 **市场** 并筛选：
   * 显存： **≥ 24 GB** （最低 RTX 4090，推荐 A100）
   * 多 GPU：筛选 GPU 数量 ≥ 2
3. 选择你的服务器并点击 **配置**.
4. 将 Docker 镜像设置为 `pytorch/pytorch:2.11.0-cuda12.8-cudnn9-devel` （基础镜像——我们会在其中安装 Mochi。）
5. 设置开放端口： `22` （SSH）和 `7860` （Gradio UI）。
6. 点击 **租用**.

{% hint style="info" %}
Clore.ai 列出了从以下价格起的 A100 40 GB 实例： [裸机](https://clore.ai/bare-metal)。对于以完整质量运行 Mochi-1，这是最具成本效益的选择。
{% endhint %}

***

## 步骤 2 — 自定义 Dockerfile

构建你自己的镜像，或使用此 `Dockerfile` 来创建一个可直接使用的 Mochi-1 环境：

```dockerfile
FROM pytorch/pytorch:2.11.0-cuda12.8-cudnn9-devel

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
    git wget curl ffmpeg \\
    libgl1 libglib2.0-0 \\
    openssh-server \
    && rm -rf /var/lib/apt/lists/*

# 配置 SSH
RUN mkdir /var/run/sshd && \
    echo 'root:clore123' | chpasswd && \
    sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \\
    sed -i 's/UsePAM yes/UsePAM no/' /etc/ssh/sshd_config

WORKDIR /workspace

# 克隆 Mochi-1 仓库
RUN git clone https://github.com/genmoai/mochi /workspace/mochi

# 安装 Python 依赖
RUN cd /workspace/mochi && \\
    pip install --upgrade pip && \\
    pip install -e . && \
    pip install gradio huggingface_hub

EXPOSE 22 7860

CMD service ssh start && \\
    echo "Mochi-1 环境已就绪。请先运行下载脚本，然后启动演示。" && \\
    tail -f /dev/null
```

### 构建并推送到 Docker Hub

在本地构建镜像并将其推送到你自己的 Docker Hub 账户（替换 `YOUR_DOCKERHUB_USERNAME` 为你的实际用户名）：

```bash
docker build -t YOUR_DOCKERHUB_USERNAME/mochi-1:latest .
docker push YOUR_DOCKERHUB_USERNAME/mochi-1:latest
```

然后在 Clore.ai 中使用 `YOUR_DOCKERHUB_USERNAME/mochi-1:latest` 作为你的 Docker 镜像。

{% hint style="info" %}
Docker Hub 上没有 Mochi-1 的官方预构建 Docker 镜像。你需要使用上面的 Dockerfile 自行构建。或者，直接使用 `pytorch/pytorch:2.11.0-cuda12.8-cudnn9-devel` 作为基础镜像，并通过 SSH 手动运行安装命令。
{% endhint %}

***

## 步骤 3 — 通过 SSH 连接

实例运行后：

```bash
ssh root@<clore-host> -p <assigned-ssh-port>
```

***

## 步骤 4 — 下载 Mochi-1 权重

模型权重托管在 Hugging Face 上。可通过以下方式下载： `huggingface_hub` CLI：

```bash
cd /workspace

# 如果尚未安装 huggingface-cli
pip install -U huggingface_hub

# 下载 Mochi-1 权重（bf16 约 40 GB）
huggingface-cli download genmo/mochi-1-preview \\
    --local-dir /workspace/mochi-weights \\
    --include "*.safetensors" "*.json" "*.txt"
```

{% hint style="info" %}
完整的 bf16 模型约为 80 GB。 `fp8` 量化版本约 40 GB，可在启用 CPU 卸载的情况下运行于 RTX 4090（24 GB）。请指定 `--include "*fp8*"` 以仅下载量化权重。
{% endhint %}

### 替代方案：仅下载 fp8 量化权重

```bash
huggingface-cli download genmo/mochi-1-preview \\
    --local-dir /workspace/mochi-weights \\
    --include "*fp8*" "*.json" "*.txt"
```

***

## 步骤 5 — 启动 Gradio 演示

Mochi-1 附带一个 Gradio 网页 UI，便于进行文本生成视频：

```bash
cd /workspace/mochi

python demos/gradio_ui.py \\
    --model_dir /workspace/mochi-weights \\
    --share False \\
    --host 0.0.0.0 \\
    --port 7860
```

**低显存模式（RTX 4090，24 GB）：**

```bash
python demos/gradio_ui.py \\
    --model_dir /workspace/mochi-weights \\
    --cpu_offload \\
    --share False \\
    --host 0.0.0.0 \\
    --port 7860
```

{% hint style="info" %}
该 `--cpu_offload` 标志会在不使用时将模型层转移到 CPU RAM，从而将峰值显存降至约 18–20 GB，但生成速度会变慢约 2 倍。
{% endhint %}

***

## 步骤 6 — 访问网页 UI

打开浏览器并访问：

```
http://<clore-host>:<public-port-7860>
```

你将看到带有以下内容的 Mochi-1 Gradio 界面：

* 文本提示输入框
* 生成设置（步数、引导比例、种子）
* 视频输出播放器

***

## 步骤 7 — 生成你的第一个视频

### 示例提示词

**自然场景：**

```
在郁郁葱葱的热带雨林中，一道雄伟的瀑布倾泻而下， 
金色时刻的阳光穿过树冠，慢速电影感横移
```

**动作场景：**

```
一只猎豹在开阔的稀树草原上全速奔跑， 
身后扬起尘土，戏剧性的广角镜头，4K 野生动物纪录片
```

**抽象/艺术风格：**

```
彩色颜料在水中以极慢动作旋转， 
鲜艳的蓝色和橙色颜料相互混合，微距镜头，棚拍灯光
```

### 推荐设置

| 参数   | 数值          |
| ---- | ----------- |
| 步数   | 64          |
| 引导比例 | 4.5         |
| 时长   | 5.1 秒（默认）   |
| 分辨率  | 848×480（原生） |

{% hint style="info" %}
生成时间因 GPU 而异，差别很大。在 A100 80 GB 上，生成一段 5 秒视频大约需要 **2–4 分钟**。在 RTX 4090 搭配 CPU 卸载时，预计需要 **8–15 分钟**.
{% endhint %}

***

## Python API 用法

如需程序化生成，请使用 diffusers 管线：

```python
import torch
from diffusers import MochiPipeline
from diffusers.utils import export_to_video

# 加载管道
pipe = MochiPipeline.from_pretrained(
    "/workspace/mochi-weights",
    torch_dtype=torch.bfloat16
)
pipe.enable_model_cpu_offload()
pipe.enable_vae_slicing()

# 生成视频
with torch.autocast("cuda", torch.bfloat16, cache_enabled=False):
    frames = pipe(
        prompt="一只金毛寻回犬在阳光明媚的海滩上玩接飞盘，电影感",
        num_frames=84,
        guidance_scale=4.5,
        num_inference_steps=64,
        generator=torch.Generator("cuda").manual_seed(42)
    ).frames[0]

# 导出
export_to_video(frames, "output.mp4", fps=30)
print("视频已保存到 output.mp4")
```

### 批量生成脚本

```python
import torch
from diffusers import MochiPipeline
from diffusers.utils import export_to_video
import os

pipe = MochiPipeline.from_pretrained(
    "/workspace/mochi-weights",
    torch_dtype=torch.bfloat16
)
pipe.enable_model_cpu_offload()

prompts = [
    "一只蝴蝶以慢动作落在花朵上，微距摄影",
    "日落时分，海浪撞击岩石峭壁，航拍镜头",
    "北极光在冰封湖面上方的繁星夜空中舞动",
]

os.makedirs("/workspace/outputs", exist_ok=True)

for i, prompt in enumerate(prompts):
    frames = pipe(
        prompt=prompt,
        num_frames=84,
        guidance_scale=4.5,
        num_inference_steps=64,
    ).frames[0]
    
    output_path = f"/workspace/outputs/video_{i:03d}.mp4"
    export_to_video(frames, output_path, fps=30)
    print(f"已保存：{output_path}")
```

***

## 多 GPU 推理

如需使用多张 GPU 加快生成速度：

```python
import torch
from diffusers import MochiPipeline

# 使用 device_map 进行自动多 GPU 分配
pipe = MochiPipeline.from_pretrained(
    "/workspace/mochi-weights",
    torch_dtype=torch.bfloat16,
    device_map="balanced"
)

# 多 GPU 时无需 cpu_offload
frames = pipe(
    prompt="这里填写你的提示词",
    num_frames=84,
    guidance_scale=4.5,
    num_inference_steps=64,
).frames[0]
```

{% hint style="info" %}
Clore.ai 提供多 GPU 服务器（2×、4× RTX 4090 或 A100）。使用 2× A100 80 GB 时，生成一段 5 秒视频的时间可降至 60 秒以内。
{% endhint %}

***

## 故障排查

### CUDA 显存不足

```
torch.cuda.OutOfMemoryError：CUDA 显存不足
```

**解决方案：**

1. 在 `--cpu_offload` 添加到 gradio 命令中
2. 启用 VAE slicing： `pipe.enable_vae_slicing()`
3. 减少 `num_frames` （试试 24 而不是 84）
4. 使用 fp8 量化权重代替 bf16

### 模型加载缓慢

**解决方案：** 确保权重位于高速 NVMe 磁盘上，而不是 HDD。检查存储速度：

```bash
dd if=/dev/zero of=/workspace/test bs=1M count=1000 conv=fdatasync
```

### 视频伪影 / 时间闪烁

**解决方案：**

* 增加推理步数（试试 80–100）
* 调整引导比例（通常 3.5–5.0 范围最佳）
* 使用特定种子以便复现和迭代

### 7860 端口无法访问

检查该端口是否已在 Clore.ai 中正确开放，以及 Gradio 服务器是否正在绑定到 `0.0.0.0`:

```bash
ss -tlnp | grep 7860
```

***

## 成本估算

| GPU          | 显存     | 预估价格                              | 5 秒视频时长    |
| ------------ | ------ | --------------------------------- | ---------- |
| RTX 4090     | 24 GB  | $0.14–0.42/小时                     | \~10–15 分钟 |
| A100 40GB    | 40 GB  | [裸机](https://clore.ai/bare-metal) | \~3–5 分钟   |
| A100 80GB    | 80 GB  | [裸机](https://clore.ai/bare-metal) | \~2–3 分钟   |
| 2× A100 80GB | 160 GB | [裸机](https://clore.ai/bare-metal) | \~60–90 秒  |

***

## Clore.ai GPU 推荐

{% hint style="warning" %}
**Clore.ai 市场上未列出多 GPU 的 80GB 级机型。** 目前列出的最大配置是 4× RTX PRO 6000 Blackwell（每张 96GB，共 380GB）以及 8–11× RTX 5090（每张 32GB）。A100 / H200 / B200 容量可按 [裸机](https://clore.ai/bare-metal) 需求提供。部署前请查看 [GPU 价格与可用性](/guides/guides_v2-zh/ru-men-zhi-nan/pricing.md) 。
{% endhint %}

Mochi-1 非常占用显存——这款 100 亿参数模型需要谨慎选择 GPU。

| GPU          | 显存     | Clore.ai 价格                       | 模式          | 5 秒视频生成时间  |
| ------------ | ------ | --------------------------------- | ----------- | ---------- |
| RTX 4090     | 24 GB  | $0.14–0.42/小时                     | 仅 fp8 量化    | \~10–15 分钟 |
| A100 40GB    | 40 GB  | [裸机](https://clore.ai/bare-metal) | 推荐 bf16     | \~3–5 分钟   |
| A100 80GB    | 80 GB  | [裸机](https://clore.ai/bare-metal) | 完整 bf16，速度快 | \~2–3 分钟   |
| 2× A100 80GB | 160 GB | [裸机](https://clore.ai/bare-metal) | 张量并行，最快     | \~60–90 秒  |

{% hint style="warning" %}
**不推荐 RTX 3090（24GB）** —— Mochi-1 在 fp8 模式下至少需要 24GB 显存，且几乎没有余量。RTX 4090（24GB）可以在 fp8 下运行，但在较长序列上经常 OOM。为了获得可靠结果，建议从 A100 40GB 开始。
{% endhint %}

**性价比最佳：** A100 40GB，价格 [裸机](https://clore.ai/bare-metal) 可在 3–5 分钟内生成一段 5 秒视频。每个视频片段约 $0.08–0.10——明显比 Runway ML（$0.25–0.50/片）或 Pika Labs 订阅更便宜。

***

## 有用资源

* [Mochi-1 GitHub](https://github.com/genmoai/mochi)
* [Hugging Face 上的 Mochi-1](https://huggingface.co/genmo/mochi-1-preview)
* [Genmo 博客——Mochi-1 发布](https://www.genmo.ai/blog/mochi-1)
* [Diffusers Mochi 文档](https://huggingface.co/docs/diffusers/api/pipelines/mochi)
* [Mochi 提示词指南（社区）](https://github.com/genmoai/mochi/blob/main/README.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-zh/shi-pin-sheng-cheng/mochi-1.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
