• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

How to Run Stable Diffusion on Hong Kong VPS: Image API for Asia (2026)

June 15, 2026

Self-hosting Stable Diffusion on a Hong Kong VPS gives Asia-Pacific teams a private, low-latency image generation API — without the per-image pricing of Midjourney or Adobe Firefly, without sending prompts and generated images to US cloud servers, and with the flexibility to run any open-source model (SDXL, FLUX, Stable Diffusion 3.5) fine-tuned for specific styles or subject matter.

This guide covers deploying AUTOMATIC1111 WebUI (the most widely used interface) and the ComfyUI API backend on a Hong Kong VPS, including CPU-only deployment for budget plans and GPU configuration for production throughput.


Hardware Reality: CPU vs GPU Inference

Stable Diffusion inference speed is dominated by available GPU VRAM. Understanding the trade-offs upfront:

ConfigurationModel512×512 generation timeUse case
CPU only (8 vCPU)SD 1.53–8 minutesLow-volume, batch overnight
CPU only (8 vCPU)SDXL20–40 minutesNot practical for real-time
GPU (NVIDIA T4, 16 GB VRAM)SDXL8–15 secondsAPI service, small team
GPU (NVIDIA A100, 80 GB VRAM)FLUX.13–6 secondsProduction API, high volume

CPU-only deployment is practical for batch image generation tasks (overnight product photography, asset pipeline jobs) but unsuitable for real-time applications. For an API serving interactive users, a GPU-enabled VPS or dedicated server is required.

Server.HK’s dedicated server configurations include GPU options for production image generation workloads. For exploration, development, and low-volume batch use, the CPU deployment below works on any standard VPS.


Step 1: System Preparation

apt update && apt upgrade -y
apt install -y python3 python3-pip python3-venv git wget curl \
  libglib2.0-0 libsm6 libxrender1 libxext6 libgl1

# Create dedicated user for SD
useradd -m -s /bin/bash sduser
su - sduser

Step 2A: Install AUTOMATIC1111 WebUI (CPU Mode)

cd ~
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui

# Download a model (SD 1.5 — smallest practical model, ~2 GB)
mkdir -p models/Stable-diffusion
wget -O models/Stable-diffusion/v1-5-pruned-emaonly.safetensors \
  https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors

Create a launch script optimised for CPU-only operation:

cat > launch-cpu.sh << 'EOF'
#!/bin/bash
python3 launch.py \
  --skip-torch-cuda-test \
  --precision full \
  --no-half \
  --use-cpu all \
  --listen \
  --port 7860 \
  --api \
  --nowebui
EOF
chmod +x launch-cpu.sh
# Install dependencies and launch
python3 -m venv venv
source venv/bin/activate
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
./launch-cpu.sh

First launch downloads additional dependencies and takes 5–10 minutes. Subsequent launches are faster.


Step 2B: Install ComfyUI (API-First, More Efficient)

ComfyUI is the preferred backend for API use cases — lower overhead than AUTOMATIC1111, JSON-based workflow API, and better memory management for CPU inference:

cd ~
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI

python3 -m venv venv
source venv/bin/activate

# CPU-only PyTorch
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -r requirements.txt

# Download model
mkdir -p models/checkpoints
wget -O models/checkpoints/sd15.safetensors \
  https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors

# Launch
python3 main.py --listen 0.0.0.0 --port 8188 --cpu

Step 3: Expose as a Secured API via Nginx

Never expose the WebUI port (7860 or 8188) directly to the internet. Add Nginx with authentication:

exit  # Return to root
apt install nginx apache2-utils certbot python3-certbot-nginx -y

# Create API password
htpasswd -c /etc/nginx/.htpasswd apiuser

cat > /etc/nginx/sites-available/sdapi << 'EOF'
server {
    listen 80;
    server_name sdapi.yourdomain.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name sdapi.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/sdapi.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/sdapi.yourdomain.com/privkey.pem;

    client_max_body_size 50m;

    location / {
        auth_basic "SD API";
        auth_basic_user_file /etc/nginx/.htpasswd;

        proxy_pass http://127.0.0.1:8188;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 600s;  # Long timeout for CPU generation
    }
}
EOF

ln -s /etc/nginx/sites-available/sdapi /etc/nginx/sites-enabled/
certbot --nginx -d sdapi.yourdomain.com
nginx -t && systemctl reload nginx

Step 4: Generate Images via API

AUTOMATIC1111 API

import requests, base64

response = requests.post(
    "https://sdapi.yourdomain.com/sdapi/v1/txt2img",
    auth=("apiuser", "your_password"),
    json={
        "prompt": "Hong Kong skyline at night, photorealistic, 8k",
        "negative_prompt": "blurry, low quality",
        "steps": 20,
        "width": 512,
        "height": 512,
        "cfg_scale": 7
    }
)

image_data = base64.b64decode(response.json()["images"][0])
with open("output.png", "wb") as f:
    f.write(image_data)

ComfyUI API

import requests, json, uuid

# ComfyUI uses a workflow-based JSON API
workflow = {
    "3": {
        "inputs": {"seed": 42, "steps": 20, "cfg": 7,
                   "sampler_name": "euler", "scheduler": "normal",
                   "denoise": 1, "model": ["4", 0],
                   "positive": ["6", 0], "negative": ["7", 0],
                   "latent_image": ["5", 0]},
        "class_type": "KSampler"
    },
    "6": {"inputs": {"text": "Hong Kong city, night, cinematic", "clip": ["4", 1]},
          "class_type": "CLIPTextEncode"},
    "7": {"inputs": {"text": "blurry, low quality", "clip": ["4", 1]},
          "class_type": "CLIPTextEncode"}
}

client_id = str(uuid.uuid4())
response = requests.post(
    "https://sdapi.yourdomain.com/prompt",
    auth=("apiuser", "your_password"),
    json={"prompt": workflow, "client_id": client_id}
)

Step 5: Run as Systemd Service

cat > /etc/systemd/system/comfyui.service << 'EOF'
[Unit]
Description=ComfyUI Stable Diffusion
After=network.target

[Service]
User=sduser
WorkingDirectory=/home/sduser/ComfyUI
ExecStart=/home/sduser/ComfyUI/venv/bin/python main.py --listen 127.0.0.1 --port 8188 --cpu
Restart=on-failure
RestartSec=10s

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable --now comfyui

Popular Open-Source Models for Asia-Pacific Use Cases

ModelSizeBest forSource
Stable Diffusion 1.52 GBGeneral use, CPU feasibleHuggingFace
SDXL 1.06.5 GBHigh quality general imagesHuggingFace
FLUX.1 schnell12 GBFast, high quality (GPU recommended)HuggingFace
Anything V52 GBAnime / illustration styleCivitAI
ChilloutMix2 GBAsian portrait photographyCivitAI
epiCRealism2 GBPhotorealistic peopleCivitAI

Use Cases for Asia-Pacific Teams

  • E-commerce product imagery — generate lifestyle backgrounds for product photos; batch-process hundreds of SKUs overnight
  • Game asset generation — character concepts, texture variations, environment sketches for game development studios in Hong Kong, Taiwan, and Japan
  • Marketing content — generate campaign visuals in brand-consistent styles using fine-tuned LoRA models
  • Design prototyping — rapid UI mockup backgrounds, illustration concepts for client presentations
  • Data augmentation — generate synthetic training data for computer vision models, particularly for Asian face recognition datasets

Conclusion

Hosting Stable Diffusion on a Hong Kong VPS provides a private, cost-effective image generation pipeline for Asia-Pacific teams — no per-image fees, no US data transfer for proprietary prompts, and low-latency API access from Hong Kong, Taiwan, and mainland China via CN2 GIA routing. CPU-only deployment works for batch jobs and development; GPU-equipped dedicated servers unlock real-time generation throughput for production API services.

Start generating: Browse Server.HK Hong Kong VPS plans for CPU batch workloads, or dedicated server options for GPU-accelerated production image generation.

Leave a Reply

You must be logged in to post a comment.

Recent Posts

  • How to Run Stable Diffusion on Hong Kong VPS: Image API for Asia (2026)
  • How to Deploy GitLab CE on Hong Kong VPS: Self-Hosted Git and CI/CD (2026)
  • Hong Kong VPS vs Google Cloud Asia: CN2 GIA vs GCP asia-east2 (2026)
  • Hong Kong VPS vs AWS Lightsail: True Cost and Performance for Asia (2026)
  • Hong Kong VPS vs Vultr: Which Is Better for Asia-Pacific Developers? (2026)

Recent Comments

  1. Hong Kong VPS Uptime and SLA: What 99.9% Uptime Really Means for Your Business (2026) - Server.HK on How to Monitor Your Hong Kong VPS: Uptime, Performance, and Alert Setup Guide (2026)
  2. Best Hong Kong VPS Providers in 2026: Compared by Speed, Routing, and Value - Server.HK on How to Migrate Your Website to a Hong Kong VPS: Zero-Downtime Transfer Guide (2026)
  3. vibramycin injection on How to Choose the Right Hong Kong VPS Plan: A Buyer’s Guide for 2026
  4. allopurinol for gout on CN2 GIA vs BGP vs CN2 GT: What’s the Real Difference for China Connectivity?
  5. antibiotics online purchase on How to Set Up a WordPress Site on a Hong Kong VPS with aaPanel (Step-by-Step 2026)

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot