Installing ComfyUI on Ubuntu 24.04


Installing ComfyUI on Ubuntu 24.04

I’m quite late to the game, but I decided to try out image generation AI and installed ComfyUI on Ubuntu.

Basically, I just needed to follow the ComfyUI Wiki.

comfycli

Terminal window
python -m venv comfy-env
source comfy-env/bin/activate
pip install comfy-cli
comfy --install-comp
comfy install
pip3 install torch torchvision torchaudio
comfy launch -- --listen 0.0.0.0

It was installed in ~/comfy/ComfyUI/. By using --listen 0.0.0.0, I can access it from a browser on another PC via ip address:8188.

Auto-start with systemd

Create a startup script

Terminal window
vim ~/comfy/comfyui-start.sh
comfyui-start.sh
#!/bin/bash
cd /home/myusername/comfy
source /home/myusername/.bashrc
source /home/myusername/comfy-env/bin/activate
comfy launch -- --listen 0.0.0.0
Terminal window
chmod +x ~/comfy/comfyui-start.sh

Create a systemd unit file

Terminal window
sudo vim /etc/systemd/system/comfyui.service
comfyui.service
[Unit]
Description=ComfyUI Service
After=network.target
[Service]
Type=simple
User=myusername
ExecStart=/home/myusername/comfy/comfyui-start.sh
Restart=always
WorkingDirectory=/home/myusername/comfy/ComfyUI
[Install]
WantedBy=multi-user.target

Register with systemd

Terminal window
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enabel comfyui
sudo systemctl start comfyui
systemctl status comfyui

Author

me

Fumito Iriya

Scientist (Ph.D.), Programer, Web Developer, Guitarist, Photographer

more...