VPS Tutorials
ComfyUI on GPU VPS: Docker, Models, HTTPS and Batches (2026)
Deploy ComfyUI on an NVIDIA GPU cloud server, match drivers and runtime, persist models, protect access and recover batch jobs while checking VRAM, storage and billing.

ComfyUI can run on CPU, but useful generation speed usually calls for a supported GPU. This procedure targets an NVIDIA GPU cloud server: validate drivers, deploy a container, persist models and outputs, protect access, then submit a small workflow before attempting batches. A 1024×1024 CPU render may take many minutes; actual time depends on model, hardware and settings.
For hardware selection see GPU VPS guidance. The tutorial itself applies across regions; its original RMB budgets are China-market examples, not current international prices.
An 8 GB laptop RTX 4060 can suit some SDXL workflows yet run out of memory with a heavier Flux configuration. This is workload-dependent, not a benchmark or a claim of our own testing. Renting a GPU makes sense when:
- Your local VRAM cannot hold the model/workflow.
- You need unattended batches, such as hundreds of authorized dataset images.
- A team needs shared models and workflows.
- A temporary project does not justify buying hardware.
Occasional generation may be cheaper locally. The original estimated continuous RTX 4090 rental around CNY 3000/month; verify an actual quote, taxes and billing conditions.
| Arrangement | Billing | After stopping | Data considerations |
|---|---|---|---|
| Local GPU | Purchase plus electricity | No cloud compute charge | Local storage and backups |
| Usage-based GPU cloud | Seconds/hours depending on provider | Compute stops only under the provider's defined stop/release rules; storage can continue | Ephemeral disk may disappear on release |
| Monthly GPU VPS/dedicated server | Monthly contract | Usually still billed | Persistence depends on contract and disk failure protection |
Original examples were CNY 2–4/hour and CNY 2000–4000/month for a 4090. They do not establish worldwide prices. Test a few hours first; calculate storage, transfer and idle time before choosing a monthly service. A stopped instance and a released instance are different operations.
VRAM capacity determines whether a workflow fits; speed also depends on compute, kernels, bandwidth and offloading. These are approximate planning figures from the original, not guaranteed minimums:
| Model | File size | Indicative VRAM | Planning example |
|---|---|---|---|
| SD 1.5 | ~2 GB | ~4 GB | 6 GB card |
| SDXL | ~6.9 GB | ~7–8 GB | 8 GB tight; 12 GB provides room |
| Flux.1 dev fp16 | ~23 GB | 20 GB+ | 24 GB RTX 3090/4090; offloading may change requirements |
| Flux.1 dev fp8 | ~12 GB | ~11 GB | 12 GB under suitable settings |
| Flux GGUF Q5_K_S | ~8.5 GB | ~7.5 GB | 8 GB tight; 12 GB more room |
| Flux GGUF Q4_K_S | ~6.8 GB | ~6.5 GB | 6–8 GB remains constrained |
Budget disk for VAE, ControlNet, upscalers and LoRA too: 100 GB can fill quickly. NVMe generally helps model loading, without guaranteeing a particular speedup. A 32 GB RAM starting budget is useful for offloading; measure the actual workflow, since RAM/swap is much slower than VRAM. Test model-download connectivity from the chosen region instead of assuming speed from a provider's country.
nvidia-smi
Check device, VRAM and driver. The CUDA number shown by nvidia-smi indicates driver capability, not necessarily the runtime installed in the container. A missing command does not alone prove the GPU driver is absent; consult the provider's supported image and management tools.
Install NVIDIA Container Toolkit using the official repository instructions before these package/configuration commands if your distribution lacks the repository. Restarting Docker affects other containers:
sudo apt update
sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
docker run --rm --gpus all nvidia/cuda:12.8.0-base-ubuntu24.04 nvidia-smi
The 12.8 test only validates that particular container path; it does not prove compatibility with a CUDA 13 application. Match host driver, GPU architecture and the actual image runtime before proceeding.
mkdir -p ~/comfyui/{models,custom_nodes,input,output,user}
cd ~/comfyui
Create docker-compose.yml:
services:
comfyui:
image: yanwk/comfyui-boot:cu130-slim-v2
container_name: comfyui
restart: unless-stopped
ports:
- "127.0.0.1:8188:8188"
volumes:
- ./models:/root/ComfyUI/models
- ./custom_nodes:/root/ComfyUI/custom_nodes
- ./input:/root/ComfyUI/input
- ./output:/root/ComfyUI/output
- ./user:/root/ComfyUI/user
environment:
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=compute,utility
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
shm_size: "8gb"
The example tag cu130-slim-v2 was present in the publisher’s registry when checked on 2026-11-16, with digest sha256:ad3e5eb6b791a93a5f62d5ce8007ee02fb1ecfbab9b758d4da0f6e95809f5a9d. Availability does not establish driver compatibility or a security review; verify and pin the artifact selected for your own GPU.
The community image/tag shown is an example to verify against its publisher's current documentation, then pin by reviewed version/digest. CUDA 13.0 is not a universal ComfyUI requirement; supported PyTorch builds and node dependencies decide compatibility. Verify what the image includes, including Manager, rather than assuming all tags are identical.
Use 127.0.0.1:8188:8188, avoiding 8188:8188, so direct unauthenticated access stays private. shm_size: "8gb" increases shared-memory capacity above Docker's common 64 MB default; size it for RAM and workloads rather than treating 8 GB as always necessary.
docker compose up -d
docker compose logs -f
Check listening port 8188 and Total VRAM in the logs against the assigned GPU. Check permissions for every mounted directory and retain configuration/user state as well as models.
Under models:
| Directory | Purpose |
|---|---|
checkpoints/ | Compatible complete checkpoints |
unet/ | Separate UNet/diffusion models and GGUF where the installed loader expects them |
clip/ | Text encoders; a Flux workflow may need t5xxl and clip_l |
vae/ | VAE |
loras/ | LoRA |
controlnet/ | ControlNet |
embeddings/ | Textual inversion embeddings |
upscale_models/ | Upscalers such as ESRGAN |
Refresh the model list after copying. A repository's Diffusers shards are not automatically a single loadable checkpoint: follow a compatible workflow's exact artifact layout. The following original example uses a third-party China-oriented mirror. It is optional; review trust, availability and licenses, and prefer the official endpoint where suitable:
export HF_ENDPOINT=https://hf-mirror.com
pip install -U "huggingface_hub[cli]"
hf download black-forest-labs/FLUX.1-schnell \
--include "*.safetensors" \
--local-dir ~/comfyui/models/checkpoints
Civitai downloads may require an authorized account or token. Replace the placeholder with the correct private URL; wget -c resumes only if the source supports it:
wget -c -O ~/comfyui/models/checkpoints/model.safetensors "复制的直链"
Start with one compatible SDXL model and one or two LoRA. Verify a complete render before downloading a 200 GB collection. Custom nodes execute code: review their source/dependencies and restrict access to their installer.
Treat the deployment as unauthenticated unless you have verified its authentication layer. TLS alone does not stop others consuming GPU time. This Caddy example combines proxying and credentials; replace placeholders, use the syntax accepted by your installed Caddy (current releases use basic_auth), and validate before reload:
comfy.example.com {
encode gzip
basicauth {
admin $2a$14$这里换成你的密码哈希
}
reverse_proxy 127.0.0.1:8188
}
Generate the hash privately; passing a password on the command line can leave shell-history/process exposure, so prefer the tool's interactive input:
caddy hash-password --plaintext '你的密码'
Correct DNS and reachable ACME challenge routes are necessary. WebSocket upgrades carry progress/previews; check browser errors if the page opens without updates. Cloudflare Tunnel still needs an access policy; hiding origin addressing does not provide authentication.
For single-user access, use a private SSH tunnel:
ssh -L 8188:127.0.0.1:8188 user@你的服务器
Open http://127.0.0.1:8188 on your own computer. Keep the local forwarded port private and protect the SSH account; a public proxy is unnecessary for this access path.
Enable Developer Mode Options and use Export (API), according to the installed UI, to save API-format JSON. Ordinary visual workflow JSON is different. Adapt the example's node IDs and input fields to your workflow:
import json, time, uuid, urllib.request
SERVER = "http://127.0.0.1:8188"
CLIENT_ID = str(uuid.uuid4())
with open("workflow_api.json") as f:
wf = json.load(f)
# 改掉节点里的提示词和随机种子
wf["6"]["inputs"]["text"] = "a cat sitting on a server rack, cinematic lighting"
wf["3"]["inputs"]["seed"] = 12345
payload = json.dumps({"prompt": wf, "client_id": CLIENT_ID}).encode()
req = urllib.request.Request(
f"{SERVER}/prompt", data=payload,
headers={"Content-Type": "application/json"},
)
prompt_id = json.loads(urllib.request.urlopen(req).read())["prompt_id"]
while True:
with urllib.request.urlopen(f"{SERVER}/history/{prompt_id}") as r:
history = json.loads(r.read())
if prompt_id in history:
break
time.sleep(1)
for node in history[prompt_id]["outputs"].values():
for img in node.get("images", []):
print(img["filename"], img.get("subfolder", ""))
/promptexpects node IDs as strings: use["4", 1], not[4, 1]./historycan be empty while queued/running. Check queue and errors; poll at roughly 1 second initially, not every 100 ms./historyis not durable across restarts. Persistprompt_id, workflow, seeds and outputs; a stored ID alone cannot restore erased server history./promptaccepting a request is not successful generation. Check execution status/errors, required fields and/object_infofor installed nodes. Some invalid workflows fail validation immediately./promptqueues work; bound the submission rate, add timeouts and stop/error handling. The original loop is only a minimal demonstration and can wait forever after failures.
For CUDA out of memory, inspect competing GPU use first. Do not immediately switch to --lowvram. Check supported flags in the installed version and try this progression:
Default → --normalvram → --lowvram → --novram → --cpu.
- Intermittent SDXL OOM on 12 GB: evaluate
--reserve-vram 2to leave headroom. - Model-switching or cache pressure: evaluate
--cache-none. - Older 10/20-series GPUs with Flux: consider
--use-split-cross-attentionand--lowvramif supported; dependencies can exclude old architectures. - Fragmentation/offloading trouble: evaluate
--disable-dynamic-vramagainst current documentation.
| Quantization | File | Indicative VRAM | Tradeoff |
|---|---|---|---|
| fp16 | ~23 GB | 20 GB+ | High precision, large memory budget |
| fp8 | ~12 GB | ~11 GB | Lower memory; compatibility and quality vary |
| Q5_K_S | ~8.5 GB | ~7.5 GB | Loader required; quality/speed depend on workflow |
| Q4_K_S | ~6.8 GB | ~6.5 GB | Further compression, possible detail loss |
GGUF needs a reviewed ComfyUI-GGUF node and Unet Loader (GGUF); use models/unet/ rather than checkpoints/ where that loader expects it. Reduce resolution from 1024 to 768, batch size from 4 to 1, and separate workflows loading two large models. Measure memory savings; no fixed percentage applies to every workflow.
Stop or release usage-based compute using the provider's actual billing operation; an in-guest shutdown may not suffice. Use provider scheduling where appropriate. Back up important models/outputs before releasing ephemeral storage; retained stopped disks may remain billable. Check model-download and output-transfer rates, and avoid keeping expensive GPU instances alive solely for unrelated websites or databases.
Page opens but progress stalls: check WebSocket upgrades, queue, node errors and GPU activity, without assuming every failure is the proxy.
Custom nodes disappear after recreation: persist custom_nodes and record versions/dependencies.
HTTP 413 uploads: inspect every proxy/CDN body limit; Nginx commonly needs client_max_body_size. Caddy/application limits can also be configured.
Generation is slower than a benchmark: inspect nvidia-smi -l 1, VRAM/RAM offloading, resolution and sampler, and compare the same GPU/workflow. More system RAM does not fix every bottleneck.
Container exits immediately: inspect docker compose logs for occupied VRAM, driver/runtime incompatibility, permissions and failed dependencies.
Validate GPU/driver with an hourly trial, render one minimal workflow, then add models, HTTPS and batch automation. This sequence keeps a failure attributable to the layer you just changed.