How to Install ComfyUI on Linux
There are two main ways to install ComfyUI on Linux:
- Install using Comfy CLI (Recommended) - The simplest and fastest method
- Install from ComfyUI source code - Traditional manual installation method
This tutorial will cover both installation methods in detail, with a focus on recommending Comfy CLI installation.
Method 1: Install ComfyUI using Comfy CLI (Recommended)
Comfy CLI is the official command-line tool provided by ComfyUI, which greatly simplifies the ComfyUI installation and management process.
Step 1: System Environment Preparation
1. Ensure Python Environment
ComfyUI requires Python 3.9 or higher. Check your Python version:
python3 --version
If Python is not installed or the version is too low, install it following these steps:
Ubuntu/Debian systems:
sudo apt update
sudo apt install python3 python3-pip python3-venv
CentOS/RHEL/Fedora systems:
# CentOS/RHEL
sudo yum install python3 python3-pip
# Or Fedora
sudo dnf install python3 python3-pip
Arch Linux:
sudo pacman -S python python-pip
2. Install Git (if not installed)
# Ubuntu/Debian
sudo apt install git
# CentOS/RHEL
sudo yum install git
# Fedora
sudo dnf install git
# Arch Linux
sudo pacman -S git
3. Create Virtual Environment (Recommended)
Using a virtual environment can avoid package conflict issues:
# Create a virtual environment named comfy-env
python3 -m venv comfy-env
# Activate the virtual environment
source comfy-env/bin/activate
Note: You need to activate the virtual environment each time before using ComfyUI. To exit the virtual environment, use the
deactivate
command.
Step 2: Install Comfy CLI
Install comfy-cli in the activated virtual environment:
pip install comfy-cli
Configure Command Line Auto-completion (Optional)
To get a better user experience, you can enable command line auto-completion:
comfy --install-completion
Step 3: Install ComfyUI
Installing ComfyUI with comfy-cli is very simple, requiring just one command:
comfy install
This command will:
- Download and install the latest version of ComfyUI
- Automatically install ComfyUI-Manager (node manager)
- Configure basic project structure
Installation Options
You can use the following options to customize the installation:
# Install to default location ~/comfy
comfy install
# Install to specified directory
comfy --workspace=/path/to/your/workspace install
# Operate on existing ComfyUI in current directory (mainly for updates)
comfy --here install
# Operate on most recently executed or installed ComfyUI
comfy --recent install
# Install only ComfyUI, without ComfyUI-Manager
comfy install --skip-manager
Check Installation Path
You can use the following commands to check the current workspace:
# Check default workspace
comfy which
# Check workspace for specified options
comfy --recent which
comfy --here which
Step 4: Install GPU Support
NVIDIA GPU (CUDA)
If you’re using an NVIDIA GPU, you need to install CUDA support:
# Install PyTorch with CUDA support
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
Note: Please choose the corresponding PyTorch version based on your CUDA version. Visit the PyTorch website for the latest installation commands.
AMD GPU (ROCm)
If you’re using an AMD GPU:
# Install PyTorch with ROCm support
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.0
CPU Only
If running with CPU only:
# Install CPU version of PyTorch
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
Step 5: Launch ComfyUI
After installation is complete, launch ComfyUI:
comfy launch
By default, ComfyUI will run on http://localhost:8188
.
Common Launch Options
# Run in background
comfy launch --background
# Specify listen address and port
comfy launch -- --listen 0.0.0.0 --port 8080
# Use CPU mode
comfy launch -- --cpu
# Low VRAM mode
comfy launch -- --lowvram
# Stop background instance
comfy stop
Method 2: Install from ComfyUI Source Code
If you prefer the traditional installation method, you can also install directly from source code:
1. Clone ComfyUI Repository
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
2. Create Virtual Environment
python3 -m venv venv
source venv/bin/activate
3. Install Dependencies
pip install -r requirements.txt
4. Install GPU Support
Install the corresponding PyTorch version based on your GPU type (refer to the steps above).
5. Launch ComfyUI
python main.py
Post-Installation Configuration
Install Base Models
ComfyUI requires base models to function properly. You can:
- Download models from Hugging Face
- Place model files in the
models/checkpoints/
directory - Download using comfy-cli:
comfy model download --url https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned.safetensors --relative-path models/checkpoints
Troubleshooting
Common Issues
1. Permission Issues
If you encounter permission issues, ensure you have sufficient permissions to write to the installation directory:
# If using default directory, ensure ~/comfy directory is writable
ls -la ~/comfy
2. Python Version Issues
Ensure you’re using the correct Python version:
python3 --version # Should be 3.9 or higher
3. Network Connection Issues
If downloads are slow, try using a domestic mirror:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple comfy-cli
4. GPU Detection Issues
Check if GPU is properly recognized:
import torch
print(torch.cuda.is_available()) # NVIDIA GPU
print(torch.version.cuda) # CUDA version
Summary
Using Comfy CLI is the best way to install ComfyUI on Linux, offering:
- Simple installation process: Complete installation with one command
- Complete dependency management: Automatically handles all dependencies
- Multi-workspace support: Can manage multiple ComfyUI instances
- Cross-platform compatibility: Works properly on Windows, macOS, and Linux
If you’re new to ComfyUI, we strongly recommend using Comfy CLI for installation and management.
Next Steps
After installation, you can:
- 📖 Check the Complete Comfy CLI User Guide to learn more advanced features
- 🎯 Start your first ComfyUI workflow
- 🔧 Install and manage custom nodes
- 📦 Download and manage models
Related Links
- Complete Comfy CLI User Guide
- Comfy CLI GitHub Repository
- Comfy CLI Official Documentation
- ComfyUI Official Repository
- PyTorch Installation Guide