Launch a Linux GPU with SSH, clone ComfyUI, install its requirements, put models in ComfyUI/models, and start it with python main.py --listen 127.0.0.1 --port 8188. On your computer run ssh -N -L 8188:127.0.0.1:8188 to the server and open http://localhost:8188. An RTX 4090 suits SDXL and FP8 FLUX.
- Default port
- 8188
- Safe remote access
- Bind to 127.0.0.1 and use an SSH tunnel
- Built-in authentication
- None, so never expose port 8188 openly
- Starter GPU
- RTX 4090, 24 GB, $1.59/hr
- Many models loaded at once
- RTX PRO 6000, 96 GB, $4.89/hr
- API endpoints
- POST /prompt, GET /history/{id}, GET /view
- Paused machine (Wandering Giants)
- Disk only, about 3¢/hr per 50 GB
ComfyUI is a node-based interface for Stable Diffusion, FLUX and video models that runs as a small web server. That design makes it ideal for a cloud GPU: the heavy work happens on the rented card, and you drive it from a browser tab on your laptop. This tutorial installs ComfyUI on a rented Linux GPU, connects to it securely, adds models and custom nodes, and then uses ComfyUI's HTTP API so the same workflow can run from code.
It belongs to our series on running Stable Diffusion on a cloud GPU; if you only want diffusers in Python, start there.
What do you need before you start?
You need a Linux machine with an NVIDIA GPU and SSH access, a Hugging Face account if you want gated models, and an SSH client on your own computer (built into macOS, Linux and Windows 10 and later).
Pick the GPU by the heaviest model in your workflows:
| Your workflows use | GPU | VRAM | Price |
|---|---|---|---|
| SD 1.5, SDXL, ControlNets, upscalers | RTX 4090 | 24 GB | $1.59/hr |
| FLUX.1 in FP8, SD 3.5 Medium | RTX 4090 | 24 GB | $1.59/hr |
| FLUX.1 or SD 3.5 Large in full BF16, plus LoRAs | L40S | 48 GB | $1.89/hr |
| Video models (Wan, HunyuanVideo) or many models at once | RTX PRO 6000 Blackwell | 96 GB | $4.89/hr |
| Fastest per image for a busy shared instance | H100 PCIe | 80 GB | $4.99/hr |
What GPU you need for AI image generation explains these choices in detail.
Step 1: Launch a GPU and connect over SSH
Choose the Root way in so you get the whole machine. On Wandering Giants Compute that is Ubuntu with the NVIDIA driver, CUDA and PyTorch installed, plus SSH and Jupyter. Copy the SSH command from your dashboard and check the GPU:
ssh -p PORT USER@HOST
nvidia-smi
python3 -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0))"
df -h ~Step 2: Install ComfyUI
ComfyUI is a Python application. Install it in a virtual environment that can see the system PyTorch, so pip does not download another copy:
sudo apt-get update && sudo apt-get install -y git python3-venv tmux
python3 -m venv ~/comfy-venv --system-site-packages
source ~/comfy-venv/bin/activate
pip install -U pip
git clone https://github.com/comfyanonymous/ComfyUI ~/ComfyUI
cd ~/ComfyUI
pip install -r requirements.txtrequirements.txt lists torch; because the venv sees the preinstalled CUDA build, pip treats it as already satisfied. If pip starts downloading a multi-gigabyte torch wheel anyway, stop it and check pip show torch inside the venv. The project's own instructions are in the ComfyUI repository and at docs.comfy.org.
Step 3: Add models in the right folders
ComfyUI finds models by folder. Download them with huggingface-cli, logging in first if any are gated (accept the licence on the model page, then create a read token).
pip install -U "huggingface_hub[cli]" hf_transfer
export HF_HUB_ENABLE_HF_TRANSFER=1
huggingface-cli login # or export HF_TOKEN=hf_xxx
cd ~/ComfyUI
# SDXL checkpoint
huggingface-cli download stabilityai/stable-diffusion-xl-base-1.0 \
sd_xl_base_1.0.safetensors --local-dir models/checkpoints
# FLUX.1 [schnell] (Apache 2.0) diffusion model, VAE and text encoders
huggingface-cli download black-forest-labs/FLUX.1-schnell \
flux1-schnell.safetensors --local-dir models/diffusion_models
huggingface-cli download black-forest-labs/FLUX.1-schnell \
ae.safetensors --local-dir models/vae
huggingface-cli download comfyanonymous/flux_text_encoders \
clip_l.safetensors t5xxl_fp8_e4m3fn.safetensors --local-dir models/text_encodersFolder under ComfyUI/models/ | What goes there | Example |
|---|---|---|
checkpoints | All-in-one SD 1.5 / SDXL / SD 3.5 files | sd_xl_base_1.0.safetensors |
diffusion_models | Standalone diffusion transformers | flux1-dev.safetensors |
text_encoders | CLIP and T5 encoders | t5xxl_fp8_e4m3fn.safetensors |
vae | VAEs | ae.safetensors |
loras | LoRA adapters | my_style.safetensors |
controlnet | ControlNet models | depth or canny ControlNets |
upscale_models | ESRGAN-type upscalers | 4x upscalers |
Older guides use unet and clip instead of diffusion_models and text_encoders; current ComfyUI reads both. If you keep a shared model store elsewhere, edit extra_model_paths.yaml (copy it from extra_model_paths.yaml.example) rather than duplicating files. FLUX [dev] specifics, including its non-commercial licence, are in how to run FLUX on a cloud GPU.
Step 4: Start ComfyUI and open it through an SSH tunnel
Run ComfyUI inside tmux, bound to localhost, then tunnel port 8188 to your own computer. This is the safest and simplest way to reach it.
On the server:
tmux new -s comfy
source ~/comfy-venv/bin/activate
cd ~/ComfyUI
python main.py --listen 127.0.0.1 --port 8188
# Ctrl-b then d detaches; tmux attach -t comfy brings it backOn your computer:
ssh -N -L 8188:127.0.0.1:8188 -p PORT USER@HOSTNow open http://localhost:8188. The -L option forwards your local port 8188 to port 8188 on the server's loopback interface; -N means "no remote command, just forward". Leave that terminal open while you work.
Why not just use --listen?
--listen controls which network address ComfyUI binds to. With no value it means 0.0.0.0, every interface, so anyone who can reach the server's IP on port 8188 can use your ComfyUI. ComfyUI has no username or password, and with ComfyUI-Manager installed an outsider could install custom nodes, which are arbitrary Python. Use bare --listen only when something else is guarding the port: a firewall rule limited to your IP, or a reverse proxy with authentication in front. For one person, the tunnel is enough.
Useful ComfyUI start-up flags
| Flag | What it does | When to use it |
|---|---|---|
--listen 127.0.0.1 | Bind to localhost only | Always, with a tunnel |
--port 8188 | Set the HTTP port | Running several instances |
--cuda-device 1 | Use a specific GPU | Multi-GPU machines, one instance per GPU |
--highvram | Keep models in GPU memory | Big cards where you switch models often |
--lowvram | Aggressively offload to CPU RAM | Large models on small cards |
--output-directory PATH | Where images are saved | Writing to a bigger or synced disk |
Run python main.py --help for the full list in your version.
Step 5: Install ComfyUI-Manager and custom nodes
ComfyUI-Manager is a custom node that installs other custom nodes and missing models from inside the interface. Install it by cloning it into custom_nodes and restarting ComfyUI:
cd ~/ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager comfyui-manager
# restart ComfyUI in the tmux sessionA Manager button appears in the menu. When you load a shared workflow with red "missing" nodes, use Manager's "Install Missing Custom Nodes" and restart.
Custom nodes are other people's Python code running with your machine's permissions. Install ones that are widely used and maintained, and pin versions for anything you depend on. Keeping ComfyUI off the open internet matters more once Manager is installed.
Step 6: Get images and workflows in and out
Outputs land in ~/ComfyUI/output. Three easy ways to move files:
- rsync over SSH:
rsync -avz -e "ssh -p PORT" USER@HOST:~/ComfyUI/output/ ./comfy-output/ - The browser: right-click an image in ComfyUI and save it. Fine for a handful.
- Jupyter: if your machine offers Jupyter (ours does), its file browser can upload LoRAs and download output folders.
Workflows travel as JSON. Save them from the menu, commit them to Git, and every new machine can load the exact same graph.
Step 7: Call ComfyUI as an API from Python
ComfyUI exposes the same engine over HTTP, so a workflow you build visually can run from a script or a backend. In the menu, use Export (API) to save the workflow in API format; it is a JSON object keyed by node id.
import json, time, uuid, requests
COMFY = "http://127.0.0.1:8188" # run on the server, or through your tunnel
wf = json.load(open("sdxl_api.json"))
# Change the prompt text and seed. Node ids come from your exported file.
wf["6"]["inputs"]["text"] = "a red bicycle against a whitewashed wall, noon light"
wf["3"]["inputs"]["seed"] = 1234
r = requests.post(f"{COMFY}/prompt", json={"prompt": wf, "client_id": str(uuid.uuid4())})
r.raise_for_status()
prompt_id = r.json()["prompt_id"]
while True:
hist = requests.get(f"{COMFY}/history/{prompt_id}").json()
if prompt_id in hist:
break
time.sleep(1)
for node_out in hist[prompt_id]["outputs"].values():
for img in node_out.get("images", []):
params = {"filename": img["filename"], "subfolder": img["subfolder"], "type": img["type"]}
data = requests.get(f"{COMFY}/view", params=params).content
open(img["filename"], "wb").write(data)
print("saved", img["filename"])ComfyUI queues prompts internally and runs them one at a time per instance, so several clients can submit safely. For a public-facing service, put your own API in front (authentication, rate limits, job storage); how to build an AI image generation API shows that pattern with FastAPI.
How much does a ComfyUI session cost?
You pay for the minutes the GPU is on, whether ComfyUI is rendering or waiting for you to drag a node. Session cost = hours on × hourly price; pausing between sessions costs only disk.
| Session pattern | GPU | GPU time | Our cost |
|---|---|---|---|
| Evening experimenting, 3 hours | RTX 4090 | 3 h | 3 × $1.59/hr ≈ $4.77 |
| FLUX [dev] BF16 afternoon, 4 hours | L40S | 4 h | 4 × $1.89/hr ≈ $7.56 |
| Video workflow day, 8 hours | RTX PRO 6000 | 8 h | 8 × $4.89/hr ≈ $39.12 |
| Paused between sessions, 100 GB disk, 1 week | none | 168 h of disk | about 168 × 6¢ ≈ $10 |
The pause line uses our disk rate of about 3¢ an hour per 50 GB: 100 GB is about 6¢ an hour. A week paused keeps ComfyUI, your custom nodes and 100 GB of models exactly as you left them. If you only come back once a month, deleting the machine and keeping your workflow JSON and a download script is cheaper.
How per-minute billing works explains why short sessions are cheap and idle hours are not.
What goes wrong with ComfyUI on a remote GPU?
Most issues are connection, memory or missing files.
| Problem | Cause | Fix |
|---|---|---|
bind: Address already in use when tunnelling | Something local already uses 8188 | Use -L 8189:127.0.0.1:8188 and browse to port 8189 |
| Page will not load | ComfyUI not running, or tunnel closed | tmux attach -t comfy to check; restart the ssh -L command |
| Red "missing node" boxes | Workflow uses custom nodes you do not have | ComfyUI-Manager, Install Missing Custom Nodes, restart |
| Model not in the dropdown | Wrong folder or name | Check the folder table above; press R in the UI to refresh |
| Out of memory on FLUX | BF16 weights on 24 GB | Set weight dtype to fp8_e4m3fn, use the FP8 T5, or move to 48 GB |
| ComfyUI dies when SSH drops | Started outside tmux | Always start in tmux (or a systemd service) |
When does renting from Wandering Giants Compute fit?
Renting from us fits ComfyUI users who want a private machine they control: root access, Ubuntu with CUDA and PyTorch working, SSH and Jupyter, and a GPU from 24 GB up to 96 GB on one card. You pay by the minute from prepaid credit, a paused machine keeps your models for the price of its disk, and if credit runs out the machine stops itself rather than billing you further. Your prompts and outputs stay on your machine.
If you want ComfyUI pre-installed in a one-click template, or a hosted ComfyUI with nothing to manage, some other providers offer that, and Vast.ai's marketplace is cheaper per hour. For a provider comparison see the best GPU clouds for Stable Diffusion. If you are happy to run five install commands yourself, launch a GPU with Root access.
Frequently asked questions
How do I access ComfyUI on a remote server?
Start ComfyUI bound to localhost on the server, then open an SSH tunnel from your computer with ssh -N -L 8188:127.0.0.1:8188 -p PORT USER@HOST and browse to http://localhost:8188. Your browser talks to the remote ComfyUI through the encrypted SSH connection.
What does ComfyUI's --listen flag do?
--listen sets the address ComfyUI binds to. With no value it binds to 0.0.0.0, every interface, which makes it reachable from the network. --listen 127.0.0.1 keeps it local to the machine, which is what you want when you use an SSH tunnel.
Is it safe to expose ComfyUI to the internet?
Not on its own. ComfyUI has no login, and anyone who can reach it can run workflows, read outputs and, through ComfyUI-Manager, install custom nodes that execute code. Use an SSH tunnel, or put it behind a firewall and an authenticating reverse proxy.
Where do I put models in ComfyUI?
Checkpoints go in ComfyUI/models/checkpoints, LoRAs in models/loras, VAEs in models/vae, standalone diffusion models such as FLUX in models/diffusion_models, text encoders in models/text_encoders and ControlNets in models/controlnet. Symlinks work if you keep models elsewhere.
Can I use ComfyUI as an API?
Yes. Export your workflow in API format, then POST it as JSON to /prompt. ComfyUI returns a prompt_id; poll /history/{prompt_id} for the output filenames and fetch each image from /view. This is how many image services run ComfyUI headless.
How much does it cost to run ComfyUI in the cloud?
You pay for the minutes the GPU is on. A three-hour session on an RTX 4090 costs three times the hourly price; on Wandering Giants a paused machine then costs only its disk, about 3¢ an hour per 50 GB, so your models and nodes stay installed.
Rent the GPU for this, by the minute.
Launch a GPU with Ubuntu, CUDA and PyTorch ready, install ComfyUI in five commands, and pause it between sessions so your models stay put.
Prepaid credit, billed by the minute, stops itself when credit runs out. Prices in £, $, €, ¥, CA$, A$, CHF and S$; UK prices include VAT.
Keep reading
- Complete guideHow to Run Stable Diffusion on a Cloud GPU
- TutorialHow to Run FLUX Locally or on Cloud GPU Infrastructure
- GuideWhat GPU Do You Need for AI Image Generation?
- TutorialHow to Build an AI Image Generation API
- ComparisonBest GPU Cloud Providers with Per-Minute Billing
- ComparisonBest GPU Clouds for Stable Diffusion
About this article. Written by the Wandering Giants Compute team, the people who run Wandering Giants Compute. Hardware figures are the manufacturers’ published specifications. Speeds and costs marked as estimates are worked out from those specifications and our current prices, with the method shown; they are not measured benchmarks. Wandering Giants prices are taken live from our price list each time this page is built.
Last reviewed 25 November 2026.