4.0 KiB
4.0 KiB
LatentSync 1.6 部署指南
本文档描述如何在 Ubuntu 服务器上部署 LatentSync 1.6 模型。
系统要求
| 要求 | 规格 |
|---|---|
| GPU | NVIDIA RTX 3090 24GB (或更高) |
| VRAM | ≥ 18GB |
| CUDA | 12.1+ |
| Python | 3.10.x |
| 系统 | Ubuntu 20.04+ |
步骤 1: 创建 Conda 环境
# 创建新的 conda 环境
conda create -y -n latentsync python=3.10.13
conda activate latentsync
# 安装 FFmpeg
conda install -y -c conda-forge ffmpeg
步骤 2: 安装 Python 依赖
cd /home/rongye/ProgramFiles/ViGent2/models/LatentSync
# 安装 PyTorch (CUDA 12.1)
pip install torch==2.5.1 torchvision==0.20.1 --index-url https://download.pytorch.org/whl/cu121
# 安装其他依赖
pip install -r requirements.txt
步骤 3: 下载模型权重
cd /home/rongye/ProgramFiles/ViGent2/models/LatentSync
# 使用 HuggingFace CLI 下载权重
huggingface-cli download ByteDance/LatentSync-1.6 whisper/tiny.pt --local-dir checkpoints
huggingface-cli download ByteDance/LatentSync-1.6 latentsync_unet.pt --local-dir checkpoints
下载完成后,目录结构应如下:
checkpoints/
├── latentsync_unet.pt # ~2GB
└── whisper/
└── tiny.pt # ~76MB
步骤 4: 复制核心代码
从 LatentSync 官方仓库复制以下目录到本地:
# 克隆仓库 (临时)
cd /tmp
git clone https://github.com/bytedance/LatentSync.git
# 复制核心代码
cd /home/rongye/ProgramFiles/ViGent2/models/LatentSync
cp -r /tmp/LatentSync/latentsync ./
cp -r /tmp/LatentSync/scripts ./
cp -r /tmp/LatentSync/configs ./
# 清理临时文件
rm -rf /tmp/LatentSync
步骤 5: 验证安装
cd /home/rongye/ProgramFiles/ViGent2/models/LatentSync
conda activate latentsync
# 检查 PyTorch 和 CUDA
python -c "import torch; print(f'PyTorch: {torch.__version__}'); print(f'CUDA: {torch.cuda.is_available()}')"
# 运行推理测试 (使用 GPU1)
CUDA_VISIBLE_DEVICES=1 python -m scripts.inference \
--unet_config_path "configs/unet/stage2_512.yaml" \
--inference_ckpt_path "checkpoints/latentsync_unet.pt" \
--inference_steps 20 \
--guidance_scale 1.5 \
--enable_deepcache \
--video_path "test_video.mp4" \
--audio_path "test_audio.wav" \
--video_out_path "test_output.mp4"
目录结构
部署完成后,目录结构应如下:
/home/rongye/ProgramFiles/ViGent2/models/LatentSync/
├── checkpoints/
│ ├── latentsync_unet.pt
│ └── whisper/
│ └── tiny.pt
├── configs/
│ ├── scheduler_config.json
│ └── unet/
│ ├── stage1.yaml
│ ├── stage1_512.yaml
│ ├── stage2.yaml
│ ├── stage2_512.yaml
│ └── stage2_efficient.yaml
├── latentsync/
│ ├── data/
│ ├── models/
│ ├── pipelines/
│ ├── trepa/
│ ├── utils/
│ └── whisper/
├── scripts/
│ └── inference.py
├── requirements.txt
└── DEPLOY.md
故障排除
CUDA 内存不足
LatentSync 1.6 需要 ~18GB VRAM。如果遇到 OOM 错误:
- 确保使用的是 RTX 3090 或更高规格的 GPU
- 关闭其他 GPU 进程
- 降低
inference_steps(最低 10)
模型加载失败
确保以下文件存在:
checkpoints/latentsync_unet.ptcheckpoints/whisper/tiny.ptconfigs/unet/stage2_512.yaml
视频输出质量问题
调整以下参数:
inference_steps: 增加到 30-50 可提高质量guidance_scale: 增加可改善唇同步,但过高可能导致抖动