121 lines
2.8 KiB
Markdown
121 lines
2.8 KiB
Markdown
|
|
# 06 ComfyUI 装出图
|
|||
|
|
|
|||
|
|
## 目标
|
|||
|
|
|
|||
|
|
装 ComfyUI + 拉 Flux.1-dev fp8 模型 + 出第一张图。
|
|||
|
|
|
|||
|
|
## 拉 ComfyUI 代码
|
|||
|
|
|
|||
|
|
**WSL2 终端**:
|
|||
|
|
```bash
|
|||
|
|
cd /mnt/d/img-code
|
|||
|
|
git clone https://github.com/comfyanonymous/ComfyUI.git
|
|||
|
|
cd ComfyUI
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 建独立 venv(和 LLM 那个分开)
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
uv venv --python 3.11 .venv
|
|||
|
|
source .venv/bin/activate
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 装依赖
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
uv pip install -r requirements.txt
|
|||
|
|
uv pip install torch torchvision torchaudio \
|
|||
|
|
--index-url https://download.pytorch.org/whl/cu128 \
|
|||
|
|
--extra-index-url https://pypi.tuna.tsinghua.edu.cn/simple
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 让 ComfyUI 用 D 盘模型
|
|||
|
|
|
|||
|
|
**WSL2 终端**(在 ComfyUI 目录下):
|
|||
|
|
```bash
|
|||
|
|
cat > extra_model_paths.yaml << 'EOF'
|
|||
|
|
comfyui_models:
|
|||
|
|
base_path: /mnt/d/ComfyUI-models
|
|||
|
|
checkpoints: checkpoints
|
|||
|
|
vae: vae
|
|||
|
|
loras: loras
|
|||
|
|
controlnet: controlnet
|
|||
|
|
EOF
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
**这样配置后**:
|
|||
|
|
- 你把模型放 `/mnt/d/ComfyUI-models/checkpoints/`
|
|||
|
|
- ComfyUI 自动找到(不用改代码)
|
|||
|
|
|
|||
|
|
## 验证 PyTorch(同 05 章)
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
python -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0))"
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 拉 Flux.1-dev fp8 模型(16G 显存能跑)
|
|||
|
|
|
|||
|
|
**WSL2 终端**:
|
|||
|
|
```bash
|
|||
|
|
source .venv/bin/activate
|
|||
|
|
uv pip install huggingface_hub
|
|||
|
|
|
|||
|
|
python -c "
|
|||
|
|
from huggingface_hub import hf_hub_download
|
|||
|
|
import os
|
|||
|
|
os.makedirs('/mnt/d/ComfyUI-models/checkpoints', exist_ok=True)
|
|||
|
|
os.makedirs('/mnt/d/ComfyUI-models/vae', exist_ok=True)
|
|||
|
|
hf_hub_download(repo_id='Comfy-Org/Flux.1-FP8', filename='flux1-dev-fp8.safetensors', local_dir='/mnt/d/ComfyUI-models/checkpoints/')
|
|||
|
|
hf_hub_download(repo_id='Comfy-Org/Flux.1-FP8', filename='ae.safetensors', local_dir='/mnt/d/ComfyUI-models/vae/')
|
|||
|
|
print('下载完成')
|
|||
|
|
"
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
**等 10-20 分钟**(约 12 GB)。
|
|||
|
|
|
|||
|
|
## 启动 ComfyUI
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
python main.py --listen 0.0.0.0
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
**看到**:
|
|||
|
|
```
|
|||
|
|
To see the GUI go to: http://0.0.0.0:8188
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
**Windows 浏览器打开**:http://localhost:8188
|
|||
|
|
|
|||
|
|
## 出第一张图
|
|||
|
|
|
|||
|
|
1. 浏览器打开 `http://localhost:8188`
|
|||
|
|
2. 左键双击空白处 → 搜 "Load Checkpoint" → 选 `flux1-dev-fp8.safetensors`
|
|||
|
|
3. 加 "CLIP Text Encode" 节点(输入正面提示词)
|
|||
|
|
4. 加 "Empty Latent Image" 节点(设置 1024x1024)
|
|||
|
|
5. 加 "KSampler" 节点
|
|||
|
|
6. 加 "VAE Decode" + "Save Image" 节点
|
|||
|
|
7. 点 "Queue Prompt" → 等 30-60 秒
|
|||
|
|
|
|||
|
|
**第一次出图会编译 kernel,比较慢**(2-3 分钟),之后每张 5-10 秒。
|
|||
|
|
|
|||
|
|
## 模型推荐
|
|||
|
|
|
|||
|
|
| 模型 | 显存 | 速度 | 质量 |
|
|||
|
|
|------|------|------|------|
|
|||
|
|
| Flux.1-dev fp8 | 12G | 中 | ⭐⭐⭐⭐⭐ |
|
|||
|
|
| SDXL | 7G | 快 | ⭐⭐⭐⭐ |
|
|||
|
|
| SD 1.5 | 4G | 很快 | ⭐⭐⭐ |
|
|||
|
|
|
|||
|
|
**16G 显存**:
|
|||
|
|
- Flux.1-dev fp8 刚好
|
|||
|
|
- SDXL 舒服
|
|||
|
|
- SD 1.5 跑得飞快
|
|||
|
|
|
|||
|
|
## 关掉 ComfyUI
|
|||
|
|
|
|||
|
|
回到 WSL2 终端,按 `Ctrl+C`。
|
|||
|
|
|
|||
|
|
## 下一步
|
|||
|
|
|
|||
|
|
✅ 通过后 → 装更多模型 / 装 ComfyUI-Manager(一键装插件)/ 学 workflow
|