Stable Diffusion generates images from text prompts using an open-source diffusion model. This guide covers running it on a VPS, along with realistic expectations for CPU-only performance.
Important: Set Expectations First
Stable Diffusion is significantly more practical on GPU hardware — on a CPU-only VPS, image generation can take several minutes per image rather than seconds. This guide is appropriate for experimentation, low-volume personal use, or learning; not for a production feature requiring fast image generation at scale.
Prerequisites
- Ubuntu 22.04/24.04 VPS: 8+ vCPU, 16 GB+ RAM recommended for tolerable CPU-only performance
- At least 20 GB free disk space for models
Step 1 — Install Python and Dependencies
See How to Install Python on Ubuntu & Debian, then create a dedicated virtual environment:
python3 -m venv stable-diffusion-env
source stable-diffusion-env/bin/activate
Step 2 — Install AUTOMATIC1111's Web UI (Popular Community Interface)
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui
Step 3 — Launch in CPU Mode
./webui.sh --skip-torch-cuda-test --no-half --listen
These flags configure the interface to run without GPU acceleration; the first launch downloads necessary model files and dependencies, which takes considerable time.
Step 4 — Access the Web Interface
http://YOUR_SERVER_IP:7860
Step 5 — Secure Access (Important)
By default this interface has no authentication — restrict access via firewall to trusted IPs, or add authentication through a reverse proxy:
sudo ufw allow from YOUR_TRUSTED_IP to any port 7860
Step 6 — Generate Your First Image
Enter a text prompt and click Generate — expect several minutes for a single image on CPU-only hardware, depending on resolution and settings.
Reducing Generation Time
- Use a lower resolution and fewer sampling steps for faster (if lower quality) results
- Consider a smaller, distilled model variant if available for your use case
Running as a Background Service
For persistent operation beyond an interactive session, run behind a process manager or as a systemd service — see How to Manage Services with systemd and systemctl for the general pattern.
Storage Management
Generated images and downloaded models can consume significant disk space over time — monitor usage with df -h and periodically clean up unneeded generated images.
Common Errors
"CUDA not available" errors despite CPU flags — ensure --skip-torch-cuda-test is included in the launch command; some versions require it explicitly to avoid attempting GPU initialization.
Out of memory during generation — reduce image resolution/batch size, or verify sufficient RAM is available and not being consumed by other processes.
FAQ
Is there any way to meaningfully speed this up without a GPU?
Limited options exist (smaller models, lower resolution, fewer steps) but fundamentally, CPU-only image generation remains much slower than GPU acceleration; for serious volume, GPU-equipped hardware is the realistic solution.
Continue Reading
- VPS Requirements for Running AI and Machine Learning Workloads
- GPU vs CPU VPS: What You Actually Need for AI Workloads
- How to Install Python on Ubuntu & Debian
Browse more articles in AI & Machine Learning on a VPS.