Setting Up ComfyUI for Local Image Generation by node
CivNode can generate images locally using ComfyUI, a free and open-source image generation tool. This guide covers installation and setup for all platforms. ## What You Need - A GPU with at least 8GB VRAM (NVIDIA recommended, AMD works on Linux) - ComfyUI installed - A checkpoint model (we recommend DreamShaper XL Turbo for fast results) ## Installing ComfyUI ### Linux ```bash # Clone ComfyUI git clone https://github.com/comfyanonymous/ComfyUI.git cd ComfyUI # Create a virtual environment python3 -m venv venv source venv/bin/activate # Install dependencies (NVIDIA) pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu121 pip install -r requirements.txt # Download a checkpoint model (DreamShaper XL Turbo — fast, good quality) cd models/checkpoints wget https://civitai.com/api/download/models/351306 -O dreamshaper-xl-turbo.safetensors cd ../.. ``` ### macOS (Apple Silicon) ```bash git clone https://github.com/comfyanonymous/ComfyUI.git cd ComfyUI python3 -m venv venv source venv/bin/activate # Apple Silicon uses MPS acceleration automatically pip install torch torchvision pip install -r requirements.txt # Download checkpoint cd models/checkpoints curl -L https://civitai.com/api/download/models/351306 -o dreamshaper-xl-turbo.safetensors cd ../.. ``` ### Windows Download the portable package from the ComfyUI releases page on GitHub. Extract it and run. Or install manually: ```powershell git clone https://github.com/comfyanonymous/ComfyUI.git cd ComfyUI python -m venv venv venv\Scripts\activate pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu121 pip install -r requirements.txt ``` ## Starting ComfyUI for CivNode CivNode connects to ComfyUI directly from your browser. This requires CORS headers to be enabled. Always start ComfyUI with these flags: ### Linux / macOS ```bash cd ComfyUI source venv/bin/activate python main.py --listen 0.0.0.0 --enable-cors-header="*" --port 8188 ``` ### Windows ```powershell cd ComfyUI venv\Scripts\activate python main.py --listen 0.0.0.0 --enable-cors-header="*" --port 8188 ``` You can save this as a script so you don't have to type it every time. **start-comfyui.sh** (Linux/Mac): ```bash #!/bin/bash cd ~/ComfyUI source venv/bin/activate python main.py --listen 0.0.0.0 --enable-cors-header="*" --port 8188 ``` **start-comfyui.bat** (Windows): ```batch @echo off cd %USERPROFILE%\ComfyUI call venv\Scripts\activate python main.py --listen 0.0.0.0 --enable-cors-header="*" --port 8188 ``` ## Connecting CivNode to ComfyUI 1. Start ComfyUI with the flags above 2. On CivNode, go to Settings (gear icon in the sidebar) 3. Scroll to Local Image Generation (ComfyUI) 4. The URL should be http://localhost:8188 (default) 5. Click Test Connection 6. If it connects, select your checkpoint from the dropdown 7. Images will now generate locally on your machine ## Troubleshooting **Cannot reach ComfyUI** — Make sure ComfyUI is running and you started it with --enable-cors-header="*". Without CORS, your browser blocks the connection. **No checkpoints in dropdown** — Place .safetensors or .ckpt files in ComfyUI/models/checkpoints/ and restart ComfyUI. **Slow generation** — Use DreamShaper XL Turbo (6 steps) instead of full SDXL models (20+ steps). If you have less than 12GB VRAM, avoid Flux models. **AMD GPU on Linux** — Install ROCm: pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm6.0