ComfyUI on a rented GPU: a setup that survives reboots

A systemd unit, models on a persistent volume, a password in front of the UI and a simple way to time SDXL and FLUX on the RTX 4090 and 5090.

CtCheapServ teamWritten by Updated 7 min read
An easel with a glowing image next to a GPU
On this page5
  1. Layout: models on the volume, app in a unit
  2. A systemd unit
  3. Access without exposing it
  4. How to time the cards
  5. Operations

ComfyUI is a popular node-based workflow tool for image generation, and quick installs of it tend to share the same problems: the process dies when the SSH session closes, models are re-downloaded after every reinstall, and the UI is reachable by anyone who finds the port. This is a setup that fixes all three, plus a simple way to time SDXL and FLUX on the RTX 4090 and RTX 5090 plans.

Layout: models on the volume, app in a unit

Keep everything that is expensive to fetch under /data and everything that is cheap to rebuild in the app directory. A reinstall wipes the server's local disk, so if the models have to survive one, mount /data from separate storage; network storage is available on request.

/opt/comfy/                # the app, a git checkout, disposable
/data/models/checkpoints/  # SDXL, FLUX and friends: 6 to 24 GB each
/data/models/loras/
/data/models/vae/
/data/output/              # generated images

Install from the ComfyUI template, or by hand on the Ubuntu 24.04 CUDA base:

apt install -y git python3-venv
git clone https://github.com/comfyanonymous/ComfyUI /opt/comfy
python3 -m venv /opt/comfy/venv && /opt/comfy/venv/bin/pip install -U pip
/opt/comfy/venv/bin/pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128
/opt/comfy/venv/bin/pip install -r /opt/comfy/requirements.txt
git clone https://github.com/ltdrdata/ComfyUI-Manager /opt/comfy/custom_nodes/ComfyUI-Manager

Point ComfyUI at the volume with extra_model_paths.yaml so the app directory contains no models at all:

cat > /opt/comfy/extra_model_paths.yaml <<'EOF'
data:
  base_path: /data/models/
  checkpoints: checkpoints/
  loras: loras/
  vae: vae/
  clip: clip/
  unet: unet/
EOF

A systemd unit

useradd -r -m -d /opt/comfy -s /usr/sbin/nologin comfy && chown -R comfy /opt/comfy /data
cat > /etc/systemd/system/comfy.service <<'EOF'
[Unit]
Description=ComfyUI
After=network-online.target
[Service]
User=comfy
WorkingDirectory=/opt/comfy
ExecStart=/opt/comfy/venv/bin/python main.py --listen 127.0.0.1 --port 8188 --output-directory /data/output
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload && systemctl enable --now comfy

Two things in the unit are deliberate: it listens on localhost only, and it runs as an unprivileged user. Custom nodes execute arbitrary Python; a compromised node in a root process owns the server.

Access without exposing it

Pick one of two doors. The private one is Tailscale (an add-on in the order form): install it, and reach http://server-name:8188 from any of your devices with no ports open at all; change --listen to the Tailscale address. The public one is Caddy with a password, which also gives you HTTPS:

apt install -y caddy
HASH=$(caddy hash-password --plaintext 'a-long-password')
cat > /etc/caddy/Caddyfile <<EOF
comfy.example.com {
  basicauth { me $HASH }
  reverse_proxy 127.0.0.1:8188
}
EOF
systemctl reload caddy

Never publish port 8188 directly. ComfyUI has no authentication, the API can read and write files, and scanners find open instances within hours.

How to time the cards

Time the same workflows on each card with the same settings (20 steps and Euler unless noted, batch size 1) and after a warm-up run, because the first run includes loading the models from disk. ComfyUI logs how long every run takes, so journalctl -u comfy | grep 'Prompt executed' lists the results:

ModelResolutionStepsWhat it shows
SDXL 1.01024 × 102420The baseline speed of the card
SDXL + refiner1024 × 102420The cost of a second model in the pipeline
FLUX.1 dev, FP81024 × 102420Speed on a 12-billion-parameter model
FLUX.1 schnell1024 × 10244Speed for quick drafts
SDXL, batch 81024 × 102420Throughput when you generate in batches

In general the RTX 5090 is the faster card, and its 32 GB is what makes FLUX dev comfortable with a LoRA and ControlNet loaded at once; the 4090 runs it but swaps models in and out. For SDXL alone, the 24 GB of the 4090 is plenty.

Operations

  • Updates: cd /opt/comfy && git pull && venv/bin/pip install -r requirements.txt && systemctl restart comfy. Take a panel snapshot first; custom nodes break on updates more often than ComfyUI itself.
  • Reinstalls: pick the template again, reattach the volume, restore extra_model_paths.yaml and the unit; the models never move.
  • Disk: /data/output grows fast at batch sizes above one. A weekly find /data/output -mtime +30 -delete in a timer keeps it honest, after you have copied what you want to keep.
  • Watch VRAM: nvidia-smi during a generation. A workflow that fits with 1 GB to spare will fail the day you add one more node; the netdata add-on graphs it over time.

Set up this way, a GPU server survives reboots, reinstalls and your own experiments, and the only thing you touch from month to month is the workflow.

Ct
CheapServ team

Articles are written and kept up to date by the CheapServ team. Each one shows the day it was published and the day it was last changed.

Deploy your first server in under a minute.

Top up from $25 in BTC, ETH, XMR or USDT. Your balance never expires and unused funds are refundable.

Sign up now