ai-chatbot/dreamomni2-deploy-guide.md
Your Name 53ddb7e585
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
Initial commit - clean repository
2025-12-17 20:15:18 +08:00

279 lines
5.4 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.

# DreamOmni2 服务器部署指南
## 📋 服务器信息
- **IP**: 156.225.27.52
- **端口**: 5204
- **用户**: root
- **密码**: Jsjj@8888
## 🚀 快速部署步骤
### 步骤 1: SSH 连接到服务器
```bash
ssh -p 5204 root@156.225.27.52
```
输入密码: `Jsjj@8888`
### 步骤 2: 上传部署脚本
**方法一: 使用 SCP 上传**
在你的本地电脑终端执行:
```bash
scp -P 5204 dreamomni2-deploy.sh root@156.225.27.52:~/
```
**方法二: 直接在服务器创建**
SSH连接后,在服务器上执行:
```bash
cat > dreamomni2-deploy.sh << 'EOF'
# 这里粘贴 dreamomni2-deploy.sh 的完整内容
EOF
chmod +x dreamomni2-deploy.sh
```
### 步骤 3: 执行部署脚本
```bash
bash dreamomni2-deploy.sh
```
脚本会自动完成以下任务:
1. ✅ 检查系统信息和GPU
2. ✅ 安装系统依赖
3. ✅ 安装 Miniconda
4. ✅ 创建独立的 Python 虚拟环境
5. ✅ 安装 PyTorch (自动检测CUDA版本)
6. ✅ 克隆 DreamOmni2 仓库
7. ✅ 安装所有依赖包
8. ✅ 下载模型权重
## 📦 手动部署步骤 (如果脚本出现问题)
### 1. 连接服务器并更新系统
```bash
ssh -p 5204 root@156.225.27.52
apt update && apt upgrade -y
apt install -y git wget build-essential
```
### 2. 检查 GPU
```bash
nvidia-smi
```
### 3. 安装 Miniconda
```bash
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda3
export PATH="$HOME/miniconda3/bin:$PATH"
conda init bash
source ~/.bashrc
```
### 4. 创建虚拟环境
```bash
conda create -n dreamomni2 python=3.10 -y
conda activate dreamomni2
```
### 5. 安装 PyTorch (根据CUDA版本)
**CUDA 12.x:**
```bash
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
```
**CUDA 11.8:**
```bash
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
```
### 6. 克隆 DreamOmni2
```bash
cd ~
git clone https://github.com/dvlab-research/DreamOmni2.git
cd DreamOmni2
```
### 7. 安装依赖
```bash
pip install -r requirements.txt
pip install transformers diffusers accelerate safetensors huggingface_hub
```
### 8. 下载模型
```bash
mkdir -p models
cd models
pip install -U huggingface_hub
huggingface-cli download xiabs/DreamOmni2 --local-dir ./dreamomni2-model
```
## 🎯 使用 DreamOmni2
### 激活环境
```bash
conda activate dreamomni2
cd ~/DreamOmni2
```
### 运行推理示例
```bash
python inference.py \
--source_image ./examples/source.jpg \
--reference_image ./examples/reference.jpg \
--prompt "将源图像的风格改为参考图像的风格" \
--output ./output.jpg
```
### 创建简单测试脚本
```python
# test_dreamomni2.py
import torch
from PIL import Image
def test_model():
print("正在测试 DreamOmni2...")
print(f"PyTorch 版本: {torch.__version__}")
print(f"CUDA 可用: {torch.cuda.is_available()}")
if torch.cuda.is_available():
print(f"GPU 数量: {torch.cuda.device_count()}")
print(f"GPU 名称: {torch.cuda.get_device_name(0)}")
# 这里添加 DreamOmni2 的实际推理代码
print("✅ 环境测试通过!")
if __name__ == "__main__":
test_model()
```
运行测试:
```bash
python test_dreamomni2.py
```
## 🔧 常见问题
### Q1: 如何检查部署状态?
```bash
conda activate dreamomni2
python -c "import torch; print(f'PyTorch: {torch.__version__}, CUDA: {torch.cuda.is_available()}')"
```
### Q2: 如何查看显存使用情况?
```bash
watch -n 1 nvidia-smi
```
### Q3: 模型下载太慢怎么办?
可以使用国内镜像或者手动下载:
```bash
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download xiabs/DreamOmni2 --local-dir ./models/dreamomni2-model
```
### Q4: 如何配置 API 服务?
创建 API 服务脚本:
```python
# api_server.py
from fastapi import FastAPI, File, UploadFile
from fastapi.responses import FileResponse
import uvicorn
app = FastAPI()
@app.post("/generate")
async def generate_image(
source: UploadFile = File(...),
reference: UploadFile = File(...),
prompt: str = ""
):
# 这里添加 DreamOmni2 推理逻辑
return {"status": "success"}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
```
安装依赖并运行:
```bash
pip install fastapi uvicorn python-multipart
python api_server.py
```
## 💾 硬件要求
- **推荐**: NVIDIA RTX 3090 / 4090 或更高
- **最低显存**: 16GB VRAM
- **系统内存**: 32GB+ RAM
- **存储空间**: 50GB+ (模型 + 依赖)
## 🔐 安全建议
1. **修改SSH密码**:
```bash
passwd
```
2. **配置防火墙**:
```bash
ufw allow 5204
ufw enable
```
3. **禁用root远程登录** (可选,但推荐):
```bash
# 创建新用户
adduser aiuser
usermod -aG sudo aiuser
# 修改 /etc/ssh/sshd_config
# PermitRootLogin no
```
## 📞 获取帮助
- **GitHub Issues**: https://github.com/dvlab-research/DreamOmni2/issues
- **Hugging Face**: https://huggingface.co/xiabs/DreamOmni2
- **官网**: https://www.dreamomni2.com
## 🎉 完成后验证
```bash
# 激活环境
conda activate dreamomni2
# 检查安装
cd ~/DreamOmni2
python -c "import torch; print('✅ PyTorch安装成功')"
python -c "from transformers import AutoModel; print('✅ Transformers安装成功')"
python -c "from diffusers import StableDiffusionPipeline; print('✅ Diffusers安装成功')"
# 查看模型文件
ls -lh ~/DreamOmni2/models/dreamomni2-model/
```
如果所有检查都通过,说明部署成功!🎊