Skip to content
Follow me on X
ComfyUI Wiki

How to Install ComfyUI on Linux

⚠️ Important Notice: This documentation may not always be up-to-date. Please refer to the ComfyUI Official Repository first for the latest and most accurate installation instructions, especially for specific configurations such as AMD GPU support. The official documentation is the best source for the most current information.

There are two main ways to install ComfyUI on Linux:

  1. Install using Comfy CLI (Recommended) - The simplest and fastest method
  2. 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.

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.12 or higher (Python 3.13 is recommended). 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

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 --extra-index-url https://download.pytorch.org/whl/cu130

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, you need to install the ROCm version of PyTorch:

# Install PyTorch with ROCm support
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.4

Note: For the latest ROCm installation commands, visit the PyTorch website.

For AMD GPUs Not Officially Supported by ROCm

If your AMD GPU is not officially supported by ROCm (such as RX 6700, RX 6600, RX 7600, etc.), you can use environment variables to force enable support:

For RDNA2 architecture GPUs (such as RX 6700, RX 6600, etc.):

HSA_OVERRIDE_GFX_VERSION=10.3.0 comfy launch

For RDNA3 architecture GPUs (such as RX 7600, etc.):

HSA_OVERRIDE_GFX_VERSION=11.0.0 comfy launch

If using the source code installation method, use:

# RDNA2 GPUs
HSA_OVERRIDE_GFX_VERSION=10.3.0 python main.py
 
# RDNA3 GPUs
HSA_OVERRIDE_GFX_VERSION=11.0.0 python main.py
AMD GPU Performance Optimization Tips

On newer PyTorch versions, you can try enabling experimental memory-efficient attention to improve performance (enabled by default on RDNA3 GPUs):

TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1 comfy launch -- --use-pytorch-cross-attention

You can also try setting the following environment variable, which may improve speed (but the first run will be slower):

PYTORCH_TUNABLEOP_ENABLED=1 comfy launch

Intel GPU

If you’re using an Intel GPU:

# Install PyTorch with Intel XPU support
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/xpu

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

# 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
 
# Ultra-low VRAM mode
comfy launch -- --novram

Note: The --background parameter may no longer be supported in some versions of ComfyUI. If you need to run in the background, consider using system-level tools such as nohup or screen.

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

If you’re using an AMD GPU and encounter issues, please refer to the AMD GPU troubleshooting section below.

Post-Installation Configuration

Install Base Models

ComfyUI requires base models to function properly. You can:

  1. Download models from Hugging Face
  2. Place model files in the models/checkpoints/ directory
  3. 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.12 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. Package Build Errors (Fedora/RHEL)

If you encounter sentencepiece build errors on Fedora systems:

# Install development packages
sudo dnf install sentencepiece-devel gcc-c++ cmake

5. Alternative Package Managers

If you encounter persistent dependency issues, consider using alternative package managers:

Using Miniconda (Recommended for complex environments):

# Download and install Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
 
# Create conda environment
conda create -n comfyui python=3.12
conda activate comfyui
 
# Install ComfyUI
pip install comfy-cli
comfy install

6. GPU Detection Issues

Check if GPU is properly recognized:

import torch
print(torch.cuda.is_available())  # NVIDIA GPU
print(torch.version.cuda)         # CUDA version

7. Path and Navigation Issues

If you encounter directory navigation errors:

# Always use absolute paths or ensure you're in the correct directory
pwd  # Check current directory
ls -la  # List files in current directory
 
# Create directories if they don't exist
mkdir -p ~/comfyui-workspace
cd ~/comfyui-workspace

8. AMD GPU Issues

Issue: Error message about NVIDIA driver not found when starting

Cause: Even after installing the ROCm version of PyTorch, if the system detects NVIDIA drivers or incorrect configuration, this error may still occur.

Solutions:

  1. Verify you have installed the correct ROCm version of PyTorch:

    python -c "import torch; print(torch.__version__)"
  2. Check if you’re in a virtual environment:

    # Make sure the virtual environment is activated
    source comfy-env/bin/activate  # or your virtual environment path
  3. For non-officially supported AMD GPUs, use environment variables:

    # RDNA2 GPUs
    HSA_OVERRIDE_GFX_VERSION=10.3.0 python main.py
     
    # RDNA3 GPUs
    HSA_OVERRIDE_GFX_VERSION=11.0.0 python main.py
  4. If the problem persists, try starting in CPU mode:

    python main.py --cpu
  5. Refer to official documentation: For more AMD GPU information, please refer to the ComfyUI official repository’s AMD GPU section.

6. Virtual Environment Path Issues

Issue: Cannot find virtual environment path after closing ComfyUI

Solutions:

  1. Remember the full path of the virtual environment:

    # When creating a virtual environment, use an absolute path or remember the relative path
    cd ~/your-workspace
    python3 -m venv comfy-env
  2. Activate the virtual environment before each use:

    # Navigate to the virtual environment directory
    cd ~/your-workspace
    source comfy-env/bin/activate
  3. Use comfy-cli for management (recommended): comfy-cli automatically manages virtual environments, no manual activation needed.

  4. Create a startup script:

    # Create start-comfy.sh
    #!/bin/bash
    cd ~/your-workspace
    source comfy-env/bin/activate
    comfy launch

    Then add execute permission with chmod +x start-comfy.sh.

7. PyTorch Installation Issues

Issue: PyTorch download interrupted (Killed)

Solutions:

  1. Increase system swap space (if memory is insufficient)
  2. Use a domestic mirror:
    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
  3. Install step by step:
    pip install torch --index-url https://download.pytorch.org/whl/cu130
    pip install torchvision --index-url https://download.pytorch.org/whl/cu130
    pip install torchaudio --index-url https://download.pytorch.org/whl/cu130

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