Sign In

“ComfyUI Masterclass: The Complete Step-by-Step Guide to Local Image Generation”

2

“ComfyUI Masterclass: The Complete Step-by-Step Guide to Local Image Generation”


ComfyUI — Full Step-by-Step Guide

1) Quick overview (what is ComfyUI)

ComfyUI is an open-source, node-based GUI and backend for generative image models (Stable Diffusion family and related models). It exposes modular nodes you connect into a graph (workflow) so you can build complex image generation pipelines visually and reproducibly. Official repo and docs are the canonical sources.


2) Basic requirements (hardware + software)

  1. GPU recommended: NVIDIA GPUs with CUDA support are the usual best experience (big speed and VRAM gains). ComfyUI can run on CPU but expect slow generation.

  2. Python (3.10/3.11 typically) — installed system-wide or in a virtual environment. The installer often creates/uses a venv.

  3. PyTorch build compatible with your CUDA (matching CUDA version on your system). Mismatch between PyTorch CUDA and your NVIDIA driver/CUDA will break GPU runs.

  4. Enough disk space for model checkpoints (several GB per checkpoint for modern models).

  5. Optional but highly recommended: ComfyUI-Manager (to install and manage custom nodes, helpers).


3) Installation — the simplest path (desktop/installer) and manual

A — Desktop / portable (easiest)

  1. Download the official ComfyUI desktop/portable build (if available for your OS) from the docs/download page. The desktop package bundles Python & dependencies and is easier for beginners. Follow the desktop installer prompts.

B — Manual install (recommended for control / advanced users)

  1. Clone the ComfyUI repo:

    • git clone https://github.com/comfyanonymous/ComfyUI.git

    • cd ComfyUI

  2. Create & activate a virtual environment (optional but clean):

    • Windows: python -m venv venv && venv\Scripts\activate

    • Linux/mac: python -m venv venv && source venv/bin/activate

  3. Install dependencies. ComfyUI provides scripts or the command comfy install --fast-deps (installer helpers vary by release) — use the official instruction for the version you cloned. Make sure PyTorch matches your CUDA.

  4. Launch: python main.py (or use the shipped launcher). The UI runs in your browser (usually at http://127.0.0.1:8188 by default).

Tip: keep your ComfyUI folder inside a place you can easily update with git pull to get the latest changes.


4) First run — models & folders

  1. Models folder: Place your .ckpt / .safetensors model files into the models/checkpoints (or the path the docs specify).

  2. VAE / clip / refiner / LoRA: Put any VAE, CLIP/clip-vision models, LoRAs, or refiner models in their respective directories (models/vae, models/clip, models/lora, etc.). ComfyUI docs list the exact expected dirs.

  3. Start ComfyUI and open the default workflow to run a simple image generation to verify everything loads.


5) The UI & basic workflow (how to generate)

  1. Nodes: Left panel = node library. Drag nodes onto canvas. Connect outputs → inputs with lines.

  2. Typical minimal chain: Text PromptCLIP/TokenizerSamplerModel LoaderDecode imageSave image. (Exact node names vary by version.) Use the built-in default example workflow as your starting template.

  3. Press Run (often a “Start” or Run button). ComfyUI evaluates the graph and writes the output image(s) to your outputs folder.


6) Prompting & weights — practical tips

  1. Use concise positive prompt (subject + style keywords + camera/lighting + details). Example: detailed portrait of a woman, cinematic lighting, photorealistic, 85mm, shallow depth of field.

  2. Use negative prompt to exclude unwanted traits (e.g., blurry, extra limbs, text).

  3. ComfyUI often supports per-prompt weights and bracket syntax for emphasis. Learn the node that handles prompt text to add weights or split tokens across nodes. (Check the prompt node docs for weight syntax.)

  4. For consistency, pin seeds: set a seed node or seed field so runs are reproducible.


7) VRAM and performance: optimize so it doesn’t crash

  1. If you get CUDA OOM (out of memory): lower resolution, lower batch size, use memory optimization flags/textures, or use CPU offload/attention slicing. Many fixes are documented in ComfyUI troubleshooting.

  2. Common options: attention slicing, float16 models, rolling scheduler, and disabling CPU-heavy background apps. Also try a lighter sampler or smaller sampler steps.

  3. If you run a very low-VRAM GPU, search for low-VRAM/SDXL workflows (they exist as community recipes).


8) Common errors & fixes (the practical checklist)

  • “Failed to load checkpoint”: model file corrupted or incompatible architecture (e.g., SDXL model with non-SDXL components). Re-download the checkpoint and ensure matching model architecture for any refiner or adapter.

  • CUDA out of memory: reduce resolution/batch, enable optimizations (slicing, fp16), close other apps. See Troubleshooting page for commands.

  • Model mismatch (SDXL vs 1.5/2.1): ensure all models used in a pipeline are the same family (mixing can crash or badly distort results).

  • First-job fails / nodes missing: some workflows require specific custom nodes or models — ensure you installed required custom nodes (ComfyUI-Manager can help).

If you hit a specific error, search the ComfyUI issues page on GitHub first — many problems have detailed conversations and fixes.


9) Useful commands & maintenance

  • Update ComfyUI: inside the install folder: git pull then restart ComfyUI. If dependencies changed, run the install/update command again.

  • Installer helper: comfy install --fast-deps can speed dependency installation by using faster installers where available — check comfy install --help.


10) Extending ComfyUI: nodes, LoRA, and community tools

  1. ComfyUI-Manager: a community project to add/manage node packs and helper scripts easily — recommended if you plan to use many custom nodes.

  2. Custom nodes: create .py node scripts in custom_nodes/ — many tutorials show how to write a simple custom node in minutes. Community docs and reddit have examples.


11) Workflow design tips (how to build robust workflows)

  1. Start from a simple, working default workflow and save versions as you add complexity.

  2. Use small step increments (e.g., change one node, run, evaluate) — this narrows down causes when results are weird.

  3. Document nodes: add comments or name nodes clearly (e.g., “Prompt main”, “Upscaler pass 1”). This makes reusing workflows easier.

  4. For reproducibility, record seeds, model versions and exact node graph (export graphs if available).


12) Troubleshooting resources (where to look)

  • Official ComfyUI docs — installation, troubleshooting and nodes reference.

  • ComfyUI Troubleshooting pages for performance & model issues.

  • GitHub issues — very useful for specific errors and recent bug reports.

  • Community docs and tutorials (community wiki, Reddit threads & blogs) for walkthroughs and recipes.


13) Quick checklist before you generate (preflight)

  • [ ] Correct PyTorch + CUDA installed for your GPU.

  • [ ] Model checkpoints in the right folder and verified.

  • [ ] ComfyUI up-to-date (git pull) and dependencies installed.

  • [ ] Set reasonable image resolution for your VRAM.


14) Advanced tips & productivity hacks

  • Use fp16 versions of models to save VRAM when supported.

  • Use two-stage workflows: small preview pass (low res / fewer steps) to validate prompt + composition → final pass (full res/refiner).

  • Export and share graphs for collaboration — saves time reproducing complex setups.


15) Safety, licensing & ethical notes

  • Respect model licenses and dataset restrictions of the checkpoints you use. Some models have restrictions on commercial use or require attribution. Always check the license for each model you download.

  • Avoid generating illegal content and follow local laws and platform TOS.


2