This guide walks through setting up ComfyUI on a fresh Ubuntu 24.04 system, including automatic startup using systemd
. Perfect for render nodes or headless workstations.
I found this also works with Pop!_OS which already comes with the Nvidia drivers installed. There's a few extra caveats with Pop!_OS (such as differing kernels) on older machines that I won't go into here. For best results use the latest version of Pop!_OS with a clean install. It should also work with the latest versions of Ubuntu but I try to stick to LTS across my systems for stability and maintenance.
The below configuration has been tested on machines running RTX 3050, RTX 3090, and RTX 5090. My active nodes use 3090s since they have 24gb of VRAM and aren't crazy expensive to buy used.
Install system dependencies
sudo apt update
sudo apt install git python3 python3-venv python3-dev build-essential libgl1 ssh systemd-timesyncd -y
Install Nvidia drivers
Identify latest version
sudo ubuntu-drivers list --gpgpu
sudo apt update
sudo ubuntu-drivers install --gpgpu
sudo nvidia-cuda-toolkit
You can find more detailed instructions for on the official Ubuntu Documentation if you want to customize your setup beyond this.
Restart the machine. Once it comes back online you can verify by ensuring the following command outputs the details of your graphics card.
sudo nvidia-smi
Clone ComfyUI into ~/src
I keep my code in ~/src
across all of my machines for consistency but you can clone this anywhere. ComfyUI will use this as the base folder when running.
git clone https://github.com/comfyanonymous/ComfyUI.git ~/src/comfyanonymous/ComfyUI
Set up the Python virtual environment
cd ~/src/comfyanonymous/ComfyUI
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip wheel
pip install -r requirements.txt
Install GPU-accelerated PyTorch (Optional)
This may already be installed but it's best to double check since it can give a nice boost on some workflows.
pip install torch torchvision
Create folder for models, outputs, and other synced data
I like to sync models/outputs/workflows via SyncThing to use ComfyUI as a cluster.
mkdir ~/ComfyUI
ln -s ~/src/comfyanonymous/ComfyUI/models ~/ComfyUI/models
ln -s ~/src/comfyanonymous/ComfyUI/output ~/ComfyUI/output
ln -s ~/src/comfyanonymous/ComfyUI/custom_nodes ~/ComfyUI/custom_nodes
ln -s ~/src/comfyanonymous/ComfyUI/user/default/workers ~/ComfyUI/workflows
Now it's easy to sync just the ~/ComfyUI
folder between machines.
Manually run ComfyUI
Verify everything is working by starting the script manually.
cd ~/src/comfyanonymous/ComfyUI
source .venv/bin/activate
python3 main.py --listen 0.0.0.0
Assuming your host IP is 192.168.1.123
you can view the running service on port 8188 using the link below.
Visit ComfyUI in your browser: http://192.168.1.123:8188
If you are running everything on the same machine you are working from, you can instead leave off the --listen 0.0.0.0
and just visit using http://127.0.0.1:8188
Using 0.0.0.0 is only required if you plan to access ComfyUI over your network from other devices.
Automatic start at boot
If you want to restrict the service to only access the files you want then you can create a new user specifically for this use case. If this is a dedicated machine for just ComfyUI then you could simplify things and skip this step, using your own own user account for the service.
sudo groupadd comfyui
sudo useradd -m -g comfyui comfyui
Add yourself to the group so you can read/modify files.
sudo usermod -a -G comfyui $(whoami)
Change ownership to the user we created above:
sudo chown -R comfyui: ~/src/comfyanonymous/ComfyUI
sudo chmod -R 775 ~/src/comfyanonymous/ComfyUI
Running manually is great, but I like to power down these machines when they're not actively being used for AI since the energy usage is quite high even at idle.
Create a new systemd service file:
sudo nano /etc/systemd/system/comfyui.service
Put the following content in (change /home/marc
to your own home directory). Note that ~
will not work here, it must be an absolute path.
[Unit]
Description=ComfyUI Service
After=network-online.target
Wants=network-online.target
[Service]
User=comfyui
WorkingDirectory=/home/marc/src/comfyanonymous/ComfyUI
ExecStart=/home/marc/src/comfyanonymous/ComfyUI/.venv/bin/python3 main.py --listen 0.0.0.0
Restart=always
[Install]
WantedBy=multi-user.target
Save your file and now you can enable + start the service.
sudo systemctl daemon-reload
sudo systemctl enable comfyui
sudo systemctl start comfyui
You can now verify the service is running with:
sudo systemctl status comfyui
If the service is running you can now visit the URL in your browser the same as you did for manually starting. The difference is this will start when your machine boots up; saving you time having to login and start it manually or restart if the process dies.
The header image for this post was generated using Stable Diffusion 3.5 on a fresh node setup using this guide.