ComfyUI
ComfyUI is a powerful, node-based graphical user interface for Stable Diffusion and other generative AI models. This cheatsheet covers installation, running, keyboard shortcuts, and troubleshooting specifically for Ubuntu environments.
🚀 Installation & Setup
To get ComfyUI running with GPU acceleration on Ubuntu using uv, follow these steps.
1. Prerequisites
Ensure you have the Nvidia drivers installed. You can check this by running:
nvidia-smiInstall Python, Git, and uv (a fast Python package installer and resolver written in Rust):
sudo apt update
sudo apt install python3-pip git -y
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh2. Clone Repository
Clone the official ComfyUI repository:
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI3. Virtual Environment (Recommended)
Create a Python virtual environment using uv (this will create a .venv directory):
uv venv4. Install PyTorch with CUDA
Install PyTorch with CUDA support. Make sure to check compatibility with your installed CUDA version:
uv pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu1215. Install Dependencies
Install the remaining ComfyUI dependencies:
uv pip install -r requirements.txt🏃 Running ComfyUI
Basic Start Command
Run ComfyUI using uv run (which automatically locates and uses the virtual environment):
uv run python main.py(Alternatively, you can activate the environment via source .venv/bin/activate and run python main.py)
Command Line Arguments
Here are useful startup arguments:
| Argument | Action |
|---|---|
--listen | Listen on all network interfaces (allows access from other devices on local network) |
--port 8188 | Set the port (default is 8188) |
--enable-manager | Enable the ComfyUI-Manager extension |
--highvram / --lowvram / --novram | Force high/low/no VRAM mode (auto-detected by default) |
--use-pytorch-cross-attention | Use PyTorch cross-attention (often faster on newer GPUs) |
--preview-method auto | Enable previewing latent images while generating |
--disable-smart-memory | Disable smart VRAM management (useful if encountering OOM crashes) |
🔄 Auto-Start Script
Create a helper script run.sh in the ComfyUI root directory to quickly launch it:
#!/bin/bash
cd "$(dirname "$0")"
uv run python main.py --listen --preview-method auto --enable-managerMake it executable:
chmod +x run.sh⌨️ Keyboard Shortcuts (Web UI)
These shortcuts are essential for efficient node editing and workflow design.
Canvas Navigation & View
| Shortcut | Action |
|---|---|
| Space + Drag / Right-Click + Drag | Pan/scroll the workspace |
| Scroll Wheel / Pinch Zoom | Zoom in / out |
| Ctrl + 0 | Reset zoom to 100% |
| Alt + C | Collapse / Expand selected node |
Node Editing & Creation
| Shortcut | Action |
|---|---|
| Double Click (on canvas) | Open node search menu |
| Ctrl + Enter | Queue prompt (generate image) |
| Ctrl + S | Save current workflow to JSON |
| Ctrl + O | Load workflow from JSON |
| Ctrl + C / Ctrl + V | Copy and paste selected nodes (preserves connections inside copy) |
| Ctrl + Shift + V | Paste nodes with input connections intact |
| Alt + Drag (on a node) | Clone/duplicate the node |
| Delete / Backspace | Delete selected node(s) |
| Ctrl + G | Group selected nodes |
| Ctrl + M | Mute / unmute selected node (stops execution) |
Connections & Wires
| Shortcut | Action |
|---|---|
| Drag + Release (on empty space) | Open search menu filtered to compatible inputs/outputs |
| Ctrl + Drag (on a slot) | Move all connected wires to a different slot |
| Shift + Click (on a wire) | Add a reroute node (dot) to the wire |
| Right-Click (on input/output) | Convert between Widget (value) and Input (node connector) |
📦 Model & Path Management
Shared Model Paths (with Stable Diffusion WebUI)
If you already run AUTOMATIC1111/Stable Diffusion WebUI, you don't need to duplicate models. You can share them.
- Copy the template configuration file:bash
cp extra_model_paths.yaml.example extra_model_paths.yaml - Open
extra_model_paths.yamland edit thebase_pathundera1111to point to your WebUI installation:yamla1111: base_path: /path/to/stable-diffusion-webui
Default Model Directory Layout
Put your downloaded models in these directories under the ComfyUI root:
| Model Type | Destination Folder |
|---|---|
| Checkpoints (Base Models) | models/checkpoints/ |
| LoRA | models/loras/ |
| VAE | models/vae/ |
| ControlNet | models/controlnet/ |
| Upscalers | models/upscale_models/ |
| Embeddings (TI) | models/embeddings/ |
🛠️ ComfyUI Manager & Custom Nodes
ComfyUI-Manager is an essential custom node to install, update, and manage other custom nodes/models.
1. Install ComfyUI-Manager
Install the manager dependencies using uv:
uv pip install -r manager_requirements.txtEnable the manager by adding the --enable-manager flag when running ComfyUI:
uv run python main.py --enable-manager2. Manual Custom Node Installation
If you prefer manual Git installation:
cd custom_nodes
git clone <custom-node-repo-url>
cd <custom-node-folder>
# If they have requirements, install them using uv.
# uv automatically finds the .venv in the parent directory!
uv pip install -r requirements.txt❓ Troubleshooting (Ubuntu Specific)
1. Out of VRAM (OOM) Errors
If you run out of GPU memory:
- Add
--lowvramor--novramto your startup command. - Set
--preview-method noneto disable real-time VRAM-intensive generation previews.
2. CUDA/PyTorch Version Mismatch
If ComfyUI cannot find your GPU (running on CPU instead): Ensure your PyTorch installation matches CUDA. Verify with:
python3 -c "import torch; print(torch.cuda.is_available())"If it returns False, re-install PyTorch using the exact CUDA-enabled wheels command shown in the Installation section.
3. Monitoring GPU Usage
Open a terminal split next to ComfyUI to monitor VRAM and temperature:
watch -n 0.5 nvidia-smi