跳到主要内容

快速推理与显存优化

快速推理(Fast)​

generate_fast.py 提供带 KV 缓存的加速因果推理,逐块(chunk-by-chunk)处理视频帧,而非一次性处理全部。

先下载 Fast 权重(若尚未下载 lingbot-world-base-cam,请先下载它):

huggingface-cli download robbyant/lingbot-world-fast --local-dir ./lingbot-world-base-cam/lingbot_world_fast

运行(480P,多 GPU):

torchrun --nproc_per_node=8 generate_fast.py --task i2v-A14B --size 480*832 --ckpt_dir lingbot-world-base-cam --image examples/03/image.jpg --action_path examples/03 --dit_fsdp --t5_fsdp --ulysses_size 8 --frame_num 81 --prompt "A serene lakeside scene with a lone tree standing in calm water, surrounded by distant snow-capped mountains under a bright blue sky with drifting white clouds."

也可以使用现成脚本:

bash run_fast.sh <weights_dir> <frame_num>
# 例如:bash run_fast.sh lingbot-world-base-cam 201

显存不足怎么办​

  • 降低显存占用:加上 --t5_cpu 参数,把 T5 放到 CPU 上运行。
  • 生成更长视频:显存充足时可把 --frame_num 增大(例如 961),即可在 16 FPS 下生成约一分钟的视频。
  • 4-bit 量化模型:显存非常有限时,推荐使用社区提供的 LingBot-World-Base (Cam) 4-bit 量化版本,显著降低显存占用: 👉 https://huggingface.co/cahlen/lingbot-world-base-cam-nf4

    ⚠️ 该量化模型仅用于推理,画质与时间一致性相比全精度模型可能略有下降。

在线体验​

如果暂时不想本地部署,可在 Reactor 提供的在线 Demo 上直接体验:https://www.reactor.inc/。