Key Features
- Node-based visual workflow builder
- Support for SD 1.5, SDXL, and more
- CPU and GPU acceleration options
- Extensible with custom nodes
Prerequisites
Before starting, ensure you have:
CPU-Only Requirements
- • 4 CPU cores minimum
- • 8GB RAM (16GB recommended)
- • 50GB storage (more for models)
- • Ubuntu 22.04 or 24.04 LTS
GPU Requirements
- • RamNode GPU VPS instance
- • NVIDIA GPU with 8GB+ VRAM
- • 16GB+ system RAM
- • 100GB+ storage recommended
2
Initial Server Setup
Update System & Install Dependencies
Install Dependencies
sudo apt update && sudo apt upgrade -y
sudo apt install -y git python3 python3-pip python3-venv wget curl \
libgl1-mesa-glx libglib2.0-0 libsm6 libxext6 libxrender-devCreate Dedicated User
Create ComfyUI User
sudo useradd -m -s /bin/bash comfyui
sudo passwd comfyui
sudo usermod -aG sudo comfyui
su - comfyui3
Installation
Clone Repository & Setup Environment
Clone ComfyUI
cd /home/comfyui
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
python3 -m venv venv
source venv/bin/activate4
CPU-Only Installation
Install PyTorch for CPU
CPU PyTorch Installation
pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -r requirements.txt5
GPU Installation (NVIDIA)
Install NVIDIA Drivers & CUDA
Install CUDA Toolkit
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt update
sudo apt install -y cuda-toolkit-12-4 nvidia-driver-550Reboot & Verify
Verify GPU
sudo reboot
nvidia-smiInstall PyTorch with CUDA
GPU PyTorch Installation
pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
pip install -r requirements.txt6
Model Setup
Download Stable Diffusion Checkpoint
Download SD 1.5 Model
cd /home/comfyui/ComfyUI/models/checkpoints
wget -O sd_v1-5.safetensors "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors"ℹ️ For SDXL or other models, place them in the same directory. VAE files go in models/vae/ and LoRA files in models/loras/.
7
Systemd Service
Create Service File
Create Systemd Service
sudo nano /etc/systemd/system/comfyui.serviceService Configuration
/etc/systemd/system/comfyui.service
[Unit]
Description=ComfyUI Stable Diffusion Interface
After=network.target
[Service]
Type=simple
User=comfyui
Group=comfyui
WorkingDirectory=/home/comfyui/ComfyUI
Environment="PATH=/home/comfyui/ComfyUI/venv/bin:/usr/local/bin:/usr/bin:/bin"
ExecStart=/home/comfyui/ComfyUI/venv/bin/python main.py --listen 127.0.0.1 --port 8188
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target⚠️ For CPU-only deployments, add --cpu to the ExecStart line.
Enable & Start Service
Enable Service
sudo systemctl daemon-reload
sudo systemctl enable comfyui
sudo systemctl start comfyui
sudo systemctl status comfyui8
Nginx Reverse Proxy
Install Nginx
Install Nginx
sudo apt install -y nginx
sudo nano /etc/nginx/sites-available/comfyuiNginx Configuration
/etc/nginx/sites-available/comfyui
server {
listen 80;
server_name your-domain.com;
client_max_body_size 100M;
location / {
proxy_pass http://127.0.0.1:8188;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 300s;
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
}
}Enable Site
Enable Nginx Site
sudo ln -s /etc/nginx/sites-available/comfyui /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl restart nginx9
SSL Configuration
Install Certbot & Get Certificate
SSL Setup
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.com10
Basic Authentication
Add HTTP Basic Auth
Since ComfyUI lacks built-in authentication, add HTTP basic auth:
Create Password File
sudo apt install -y apache2-utils
sudo htpasswd -c /etc/nginx/.htpasswd comfyui_adminUpdate Nginx Location Block
Add Auth to Nginx
location / {
auth_basic "ComfyUI Access";
auth_basic_user_file /etc/nginx/.htpasswd;
# ... rest of proxy configuration
}Reload Nginx
sudo systemctl reload nginx11
Firewall Configuration
Configure UFW
Setup Firewall
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable12
Performance Optimization
CPU-Only Tuning
For CPU deployments, adjust the systemd ExecStart for better performance:
CPU ExecStart
ExecStart=/home/comfyui/ComfyUI/venv/bin/python main.py --listen 127.0.0.1 --port 8188 --cpu --lowvramMemory Management
For systems with limited RAM, add swap space:
Add Swap Space
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab13
Installing Custom Nodes
Install ComfyUI-Manager
Install Manager
cd /home/comfyui/ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager.git
sudo systemctl restart comfyuiℹ️ Access the Manager through the ComfyUI interface to browse and install additional nodes.
14
Maintenance
Updating ComfyUI
Update ComfyUI
sudo systemctl stop comfyui
cd /home/comfyui/ComfyUI
source venv/bin/activate
git pull
pip install -r requirements.txt --upgrade
sudo systemctl start comfyuiLog Monitoring
View Logs
sudo journalctl -u comfyui -fBackup Script
Backup Script
#!/bin/bash
BACKUP_DIR="/home/comfyui/backups/$(date +%Y%m%d)"
mkdir -p "$BACKUP_DIR"
cp -r /home/comfyui/ComfyUI/models "$BACKUP_DIR/"
cp -r /home/comfyui/ComfyUI/user "$BACKUP_DIR/"
cp -r /home/comfyui/ComfyUI/custom_nodes "$BACKUP_DIR/"15
Troubleshooting
| Issue | Solution |
|---|---|
| Out of memory errors | Add --lowvram or --novram flags. For CPU mode, reduce image dimensions. |
| Slow generation on CPU | Expected behavior. Use smaller models like SD 1.5 over SDXL. |
| WebSocket issues | Verify Nginx proxy includes WebSocket upgrade headers. |
| Model loading failures | Verify model files are complete. Use .safetensors format. |
