ComfyUI provides a node-based visual interface for building sophisticated Stable Diffusion image generation workflows — more powerful and flexible than simpler interfaces for complex, repeatable generation pipelines. This guide covers self-hosted setup.
ComfyUI vs Simpler Stable Diffusion Interfaces
See How to Run Stable Diffusion for AI Image Generation on a VPS for base Stable Diffusion context — ComfyUI's node-based workflow builder lets you construct and save complex, reusable generation pipelines (multi-stage generation, custom processing chains) beyond what simpler single-prompt interfaces support.
Prerequisites
- GPU-equipped VPS (see GPU vs CPU VPS: What You Actually Need for AI Workloads)
- Python environment
Step 1 — Clone ComfyUI
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
Step 2 — Install Dependencies
pip install -r requirements.txt --break-system-packages
Step 3 — Download a Model Checkpoint
mkdir -p models/checkpoints
wget -O models/checkpoints/model.safetensors [model-download-url]
Place a Stable Diffusion model checkpoint in the appropriate directory — various open-source checkpoints exist with different style/quality characteristics.
Step 4 — Start ComfyUI
python main.py --listen 0.0.0.0 --port 8188
Step 5 — Secure Access Before Exposing Beyond Localhost
See How to Set Up Nginx as a Reverse Proxy for Node.js Apps for the general reverse proxy pattern with authentication — ComfyUI has no built-in authentication by default; never expose it directly on the public internet without adding a proper authentication layer.
Building a Basic Workflow in the Node Editor
The visual interface lets you connect nodes representing each generation step (checkpoint loading, prompt encoding, sampling, VAE decoding) — understanding this node graph is the core ComfyUI skill, different from simpler prompt-box interfaces.
Saving and Reusing Workflows
Save (in UI) -> workflow.json
Workflows can be saved and shared as JSON files — useful for building a library of reusable generation pipelines for different purposes (product photography style, specific artistic effects) without rebuilding from scratch each time.
Using ComfyUI's API for Programmatic Generation
import requests
response = requests.post('http://localhost:8188/prompt', json={"prompt": workflow_json})
Beyond the visual UI, ComfyUI exposes an API for programmatic workflow execution — useful for integrating image generation into a larger application (see How to Serve a Machine Learning Model with FastAPI for the general serving pattern).
Managing GPU Memory for Complex Workflows
See How to Monitor GPU Usage on a VPS (nvidia-smi and Beyond) — complex multi-stage workflows can be memory-intensive; monitor usage and consider workflow simplification or a larger GPU allocation if you consistently hit memory limits.
Installing Custom Nodes for Extended Functionality
ComfyUI has an active ecosystem of community-contributed custom nodes extending base functionality — install from trusted sources only, since custom nodes execute code with the same permissions as ComfyUI itself, a genuine security consideration for anything installed from less-vetted sources.
Common Errors
Workflow fails partway through with a node error — check that all referenced models/checkpoints for that specific node are actually present in the expected directory; missing model files are the most common cause of workflow execution failures.
Continue Reading
- How to Run Stable Diffusion for AI Image Generation on a VPS
- How to Monitor GPU Usage on a VPS (nvidia-smi and Beyond)
- How to Serve a Machine Learning Model with FastAPI
Browse more articles in AI & Machine Learning on a VPS.