Home / AI / ComfyUI / How to Install ComfyUI on Linux (Ubuntu and Debian Guide)

How to Install ComfyUI on Linux (Ubuntu and Debian Guide)

ComfyUI is one of the most powerful node-based interfaces for running Stable Diffusion locally, and Linux is arguably the best platform to run it on. Whether you are using Ubuntu 22.04, Ubuntu 24.04, or a Debian-based distribution, the installation process is straightforward once you have the right prerequisites in place. This guide walks you through every step, from setting up your system dependencies to launching ComfyUI for the first time and keeping it updated.

Prerequisites

Before cloning the repository, you need to make sure your system has the required software. ComfyUI needs Python 3.10 or later, Git, and the correct GPU drivers and acceleration libraries for your hardware.

Python 3.10 or Later

Ubuntu 22.04 ships with Python 3.10 by default, and Ubuntu 24.04 ships with Python 3.12. Check your version first:

python3 --version

If you are on an older system, install a newer Python version using the deadsnakes PPA:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.11 python3.11-venv python3.11-dev

Git

sudo apt update
sudo apt install git

NVIDIA GPU: CUDA Toolkit

If you have an NVIDIA graphics card, you need the CUDA toolkit installed. First install the proprietary NVIDIA drivers if you have not already:

sudo apt install nvidia-driver-535
sudo reboot

Then install the CUDA toolkit. For most modern setups, CUDA 12.x is recommended:

sudo apt install nvidia-cuda-toolkit

Verify the installation with nvidia-smi and nvcc --version after rebooting.

AMD GPU: ROCm

For AMD graphics cards, you need ROCm instead of CUDA. AMD’s official ROCm installation instructions vary by distribution version, so consult the AMD ROCm documentation for your specific Ubuntu or Debian release. In broad terms, you will add the AMD repository, install rocm-hip-sdk, and add your user to the render and video groups.

Cloning and Installing ComfyUI

Once your prerequisites are ready, clone the official ComfyUI repository:

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

Create a Python virtual environment to keep ComfyUI’s dependencies isolated from your system Python:

python3 -m venv venv
source venv/bin/activate

Your terminal prompt should now show (venv) at the start. Now install the Python dependencies. For NVIDIA GPUs with CUDA 12.x:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt

For AMD GPUs with ROCm:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.6
pip install -r requirements.txt

For CPU-only use (significantly slower, not recommended for regular use):

pip install torch torchvision torchaudio
pip install -r requirements.txt

Adding Your First Model

ComfyUI will not generate anything without at least one Stable Diffusion model checkpoint. Download a model from Hugging Face or Civitai (typically a .safetensors file) and place it in:

ComfyUI/models/checkpoints/

Create the folder if it does not already exist. Good starting points for SD 1.5-based models include Realistic Vision and DreamShaper. For SDXL, Juggernaut XL and RealVisXL are popular choices. For Flux, you will need to download both the model weights and the appropriate text encoder files, which Hugging Face hosts under the black-forest-labs/FLUX.1-dev repository.

ComfyUI organises all model types into separate subdirectories under ComfyUI/models/. You will also find folders for LoRAs, ControlNet models, VAE files, and upscalers. Each type of file goes into its matching folder — do not mix them, as ComfyUI scans specific paths for each node type.

Launching ComfyUI

With your virtual environment still activated, start ComfyUI:

python main.py

Open your browser and go to http://127.0.0.1:8188. You should see the ComfyUI workflow interface.

Running on a Headless Server

If you are running ComfyUI on a remote server or a machine without a local display, use the --listen flag to bind to all network interfaces:

python main.py --listen 0.0.0.0 --port 8188

You can then access the interface from another machine on the same network using http://<server-ip>:8188. Make sure your firewall allows traffic on port 8188 if accessing from another machine.

Installing ComfyUI Manager

ComfyUI Manager is an essential extension that lets you install custom nodes, update ComfyUI, and manage models directly from the browser interface. Install it by cloning it into the custom_nodes folder:

cd custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager.git
cd ..
python main.py

After restarting, a Manager button will appear in the ComfyUI interface. From there you can browse and install hundreds of community nodes without ever touching the command line again.

Common Errors and Fixes

CUDA Not Found or torch.cuda.is_available() Returns False

This usually means PyTorch was installed without CUDA support, or the NVIDIA drivers are not correctly set up. Run the following inside your virtual environment to check:

python -c "import torch; print(torch.cuda.is_available())"

If it returns False, reinstall PyTorch with the correct CUDA index URL as shown above. Make sure nvidia-smi works at the command line first — if it does not, fix the driver installation before touching Python packages.

Missing Shared Libraries (libGL, libglib)

Some dependencies require OpenCV or similar packages that rely on shared system libraries. If you see errors referencing libGL.so.1 or similar, install the missing libraries:

sudo apt install libgl1 libglib2.0-0

Permission Denied When Writing to Models Folder

This happens if you cloned ComfyUI as root but are running it as a regular user. Fix the ownership:

sudo chown -R $USER:$USER ~/ComfyUI

Keeping ComfyUI Updated

ComfyUI is under active development. To update to the latest version, navigate to the ComfyUI directory and pull the latest changes:

cd ComfyUI
source venv/bin/activate
git pull
pip install -r requirements.txt

Running pip install -r requirements.txt after a pull ensures any new dependencies are installed. If you have ComfyUI Manager installed, you can also trigger updates directly from the browser interface via the Manager panel.

Running ComfyUI as a Systemd Service

If you want ComfyUI to start automatically when your server boots, you can run it as a systemd service. Create a service file at /etc/systemd/system/comfyui.service with the following content, adjusting the paths to match your installation:

[Unit]
Description=ComfyUI
After=network.target

[Service]
Type=simple
User=your-username
WorkingDirectory=/home/your-username/ComfyUI
ExecStart=/home/your-username/ComfyUI/venv/bin/python main.py --listen 0.0.0.0
Restart=on-failure

[Install]
WantedBy=multi-user.target

Enable and start the service with:

sudo systemctl daemon-reload
sudo systemctl enable comfyui
sudo systemctl start comfyui

Next Steps

With ComfyUI running on Linux, you are ready to start building workflows. The default workflow loads automatically when you open the interface — it is a basic text-to-image pipeline using KSampler, and it is a good place to start experimenting. From there, explore LoRAs, ControlNet, and upscaling to take your generations further.

For a full index of every ComfyUI guide on Serverman, see the ComfyUI complete guide and hub.