Stable Diffusion generates images from text prompts, and the community web UIs (AUTOMATIC1111, its faster fork Forge, and the node-based ComfyUI) make it usable from a browser. Running it on a remote server lets you generate from any device, share it with a small team, or automate image pipelines. Before you start, though, be clear on the hardware it needs.
The honest hardware picture
Image generation is dominated by GPU compute:
| Hardware | 512×512 image (SD 1.5, ~25 steps) | SDXL 1024×1024 |
|---|---|---|
| Modern NVIDIA GPU (8–24 GB VRAM) | 1–5 seconds | 5–20 seconds |
| CPU only, 4–8 vCPU | Several minutes | Often 10+ minutes, high RAM |
- For real use, you need a GPU server with an NVIDIA card and at least 8 GB of VRAM (12–24 GB for SDXL, Flux, and higher resolutions).
- CPU-only works for experiments, testing workflows, or very occasional images. It needs 16 GB+ RAM, and it ties up every core while generating.
- A regular VPS is still useful in the pipeline: as the front end (auth, queue, storage, website) that calls a GPU backend or a hosted image API.
VPS.DO’s plans are CPU-based VPS and dedicated servers, so use them for front ends, queues and storage rather than heavy inference. See VPS vs dedicated server.
Install (Ubuntu, NVIDIA GPU)
- Install the NVIDIA driver and check that
nvidia-smishows your card. - Install the prerequisites:
sudo apt install -y git python3 python3-venv libgl1 libglib2.0-0
- Clone a UI. Forge is a common choice for speed and memory efficiency:
sudo adduser --disabled-password --gecos "" sd
sudo -iu sd
git clone https://github.com/lllyasviel/stable-diffusion-webui-forge.git webui
cd webui
./webui.sh --listen --port 7860 --api
The first run creates a Python virtual environment and installs PyTorch, which takes several GB and some time. For ComfyUI, clone its repository, install the requirements into a venv, and run python main.py --listen 127.0.0.1 --port 8188.
CPU-only experiment: start with --use-cpu all --skip-torch-cuda-test --no-half, and expect it to be slow.
Models
- Put checkpoints (
.safetensors) intomodels/Stable-diffusion/, LoRAs intomodels/Lora/, and VAEs intomodels/VAE/. - Prefer
.safetensorsover.ckpt. Pickle-based.ckptfiles can execute code when loaded. - Check each model’s licence, especially for commercial use.
- Models are large (2–7 GB each), so plan disk space. See disk usage.
Run it as a service
# /etc/systemd/system/sd-webui.service
[Unit]
Description=Stable Diffusion WebUI
After=network.target
[Service]
User=sd
WorkingDirectory=/home/sd/webui
ExecStart=/home/sd/webui/webui.sh --listen --port 7860 --api
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload && sudo systemctl enable --now sd-webui
See systemd services.
Secure remote access
Never expose the web UI directly. It has no real authentication, extensions can run arbitrary code, and anyone with access can burn your GPU hours.
- SSH tunnel for personal use:
ssh -L 7860:127.0.0.1:7860 user@server, then openhttp://localhost:7860. Bind the UI to 127.0.0.1 in that case. See SSH tunnelling. - VPN (WireGuard or Tailscale) for a small team. See Tailscale.
- Nginx with HTTPS plus authentication (basic auth or SSO) if it must be on the web. Raise
client_max_body_size, and turn on WebSocket support for ComfyUI. See Nginx basic auth. - Only install extensions and custom nodes you trust. They are Python code running as your user.
Using the API
Started with --api, AUTOMATIC1111/Forge exposes /sdapi/v1/txt2img:
curl -s http://127.0.0.1:7860/sdapi/v1/txt2img -H 'Content-Type: application/json' \
-d '{"prompt":"a lighthouse at dawn, watercolor","steps":25,"width":768,"height":512}' \
| jq -r '.images[0]' | base64 -d > out.png
ComfyUI has an API for queueing workflow JSON. A web app on a regular VPS can queue jobs and store results, while the GPU machine only does the generation.
Storage and outputs
Generated images pile up quickly in outputs/. Sync them to object storage or a storage server, and clean up old files. See MinIO object storage and storage VPS.
Quick reference
| Item | Value |
|---|---|
| A1111/Forge port | 7860 (--listen, --api) |
| ComfyUI port | 8188 |
| Models | models/Stable-diffusion/ (.safetensors) |
| Minimum for real use | NVIDIA GPU, 8 GB+ VRAM |
| Remote access | SSH tunnel / VPN / Nginx + auth |
Related: LocalAI and Open WebUI.