Files
ViGent/Docs/DEPLOY_MANUAL.md
2026-01-16 16:27:30 +08:00

229 lines
4.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ViGent 手动部署指南
## 服务器信息
| 配置 | 规格 |
|------|------|
| 服务器 | Dell PowerEdge R730 |
| CPU | 2× Intel Xeon E5-2680 v4 (56 线程) |
| 内存 | 192GB DDR4 |
| GPU 0 | NVIDIA RTX 3090 24GB |
| GPU 1 | NVIDIA RTX 3090 24GB (用于 MuseTalk) |
| 部署路径 | `/home/rongye/ProgramFiles/ViGent` |
---
## 步骤 1: 环境检查
```bash
# 检查 GPU
nvidia-smi
# 检查 Python 版本 (需要 3.10+)
python3 --version
# 检查 Node.js 版本 (需要 18+)
node --version
# 检查 FFmpeg
ffmpeg -version
```
如果缺少 FFmpeg:
```bash
sudo apt update
sudo apt install ffmpeg
```
---
## 步骤 2: 创建目录结构
```bash
mkdir -p /home/rongye/ProgramFiles/ViGent
cd /home/rongye/ProgramFiles/ViGent
```
将项目文件复制到该目录。
---
## 步骤 3: 安装后端依赖
```bash
cd /home/rongye/ProgramFiles/ViGent/backend
# 创建虚拟环境
python3 -m venv venv
source venv/bin/activate
# 安装 PyTorch (CUDA 12.1)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
# 安装其他依赖
pip install -r requirements.txt
# 安装 Playwright 浏览器 (社交发布用)
playwright install chromium
```
---
## 步骤 4: 部署 AI 模型 (MuseTalk)
> ⚠️ **重要**MuseTalk 需要独立的 Conda 环境和特定的 PyTorch 版本。请**不要**直接安装在后端环境中。
请参考详细的独立部署指南:
**[MuseTalk 部署指南](../models/MuseTalk/DEPLOY.md)**
该指南包含以下关键步骤,请务必严格按照文档操作:
1. 创建独立的 `musetalk` Conda 环境
2. 安装特定版本的 PyTorch (2.0.1) 和 MMLab 依赖
3. 按照特定结构下载模型权重
4. 验证推理脚本
确保 MuseTalk 部署成功后,再继续后续步骤。
---
## 步骤 7: 配置环境变量
```bash
cd /home/rongye/ProgramFiles/ViGent/backend
# 复制配置模板
cp .env.example .env
# 编辑配置
nano .env
```
修改以下配置:
```ini
# GPU 配置
MUSETALK_GPU_ID=1
MUSETALK_LOCAL=true
# 其他配置按需修改
DEBUG=false
```
---
## 步骤 8: 安装前端依赖
```bash
cd /home/rongye/ProgramFiles/ViGent/frontend
# 安装依赖
npm install
```
---
## 步骤 9: 测试运行
### 启动后端
```bash
cd /home/rongye/ProgramFiles/ViGent/backend
source venv/bin/activate
uvicorn app.main:app --host 0.0.0.0 --port 8006
```
### 启动前端 (新开终端)
```bash
cd /home/rongye/ProgramFiles/ViGent/frontend
npm run dev -- -H 0.0.0.0 --port 3002
```
---
## 步骤 10: 验证
1. 访问 http://服务器IP:3002 查看前端
2. 访问 http://服务器IP:8006/docs 查看 API 文档
3. 上传测试视频,生成口播视频
---
## 使用 systemd 管理服务 (可选)
### 后端服务
创建 `/etc/systemd/system/vigent-backend.service`:
```ini
[Unit]
Description=ViGent Backend API
After=network.target
[Service]
Type=simple
User=rongye
WorkingDirectory=/home/rongye/ProgramFiles/ViGent/backend
Environment="PATH=/home/rongye/ProgramFiles/ViGent/backend/venv/bin"
ExecStart=/home/rongye/ProgramFiles/ViGent/backend/venv/bin/uvicorn app.main:app --host 0.0.0.0 --port 8006
Restart=always
[Install]
WantedBy=multi-user.target
```
### 前端服务
创建 `/etc/systemd/system/vigent-frontend.service`:
```ini
[Unit]
Description=ViGent Frontend
After=network.target
[Service]
Type=simple
User=rongye
WorkingDirectory=/home/rongye/ProgramFiles/ViGent/frontend
ExecStart=/usr/bin/npm run start
Restart=always
[Install]
WantedBy=multi-user.target
```
### 启用服务
```bash
sudo systemctl daemon-reload
sudo systemctl enable vigent-backend vigent-frontend
sudo systemctl start vigent-backend vigent-frontend
```
---
## 故障排除
### GPU 不可用
```bash
# 检查 CUDA
nvidia-smi
python3 -c "import torch; print(torch.cuda.is_available())"
```
### 端口被占用
```bash
# 查看端口占用
sudo lsof -i :8006
sudo lsof -i :3002
```
### 查看日志
```bash
# 后端日志
journalctl -u vigent-backend -f
# 前端日志
journalctl -u vigent-frontend -f
```