Deploy Stable Diffusion on Alibaba Cloud Serverless in Minutes

This guide shows how to map a Stable Diffusion container's dynamic paths to Alibaba Cloud NAS, configure Serverless Devs, deploy the application, and upload model files via a visual admin UI or NAS commands, enabling fast AI image generation on a cloud‑native platform.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
Deploy Stable Diffusion on Alibaba Cloud Serverless in Minutes

This article continues from a previous tutorial on using Serverless Devs and Alibaba Cloud Function Compute to quickly experience Stable Diffusion, focusing on solving the dynamic model loading problem.

Idea

The solution is to map the container's dynamic path to a NAS file storage, using NAS to store the model, language packs, and extensions. A separate visual backend can manage NAS files through simple upload and delete operations.

Preparation

Enable Alibaba Cloud Function Compute.

Create a NAS file storage instance (or use an existing one).

Enable Alibaba Cloud Container Registry (ACR).

Install Serverless Devs: $ npm install @serverless-devs/s -g Configure Alibaba Cloud credentials with Serverless Devs.

Quick Start

Initialize the template and deploy: s init fc-stable-diffusion-plus Select region cn-hangzhou and image

registry.cn-hangzhou.aliyuncs.com/serverlessdevshanxie/sd-auto-nas:v1

. cd fc-stable-diffusion-plus && s deploy Deployment takes about five minutes and returns two domain URLs.

fc-nas-init:
  region: cn-hangzhou
  service:
    name: fc-stable-diffusion-plus
  function:
    name: nas-init
    runtime: python3.9
    handler: index.handler
    memorySize: 3072
    timeout: 1200
    cpu: 2
    diskSize: 512

fc-nas-filemgr:
  region: cn-hangzhou
  service:
    name: fc-stable-diffusion-plus
  function:
    name: admin
    runtime: custom
    handler: index.handler
    memorySize: 3072
    timeout: 7200
    cpu: 2
    diskSize: 512
    url:
      system_url: https://xxx.cn-hangzhou.fcapp.run
      system_intranet_url: https://xxx.cn-hangzhou-vpc.fcapp.run
      custom_domain:
        - domain: http://admin.fc-stable-diffusion-plus.xxxx.cn-hangzhou.fc.devsapp.net
  triggers:
    - type: http
      name: httpTrigger

keep-warm:
  region: cn-hangzhou
  service:
    name: fc-stable-diffusion-plus
  function:
    name: keep-warm
    runtime: python3
    handler: index.handler
    memorySize: 128
    timeout: 120
    cpu: 0.1
    diskSize: 512
  triggers:
    - type: timer
      name: timerTrigger

stable-diffusion-sd-server:
  region: cn-hangzhou
  service:
    name: fc-stable-diffusion-plus
  function:
    name: sd
    runtime: custom-container
    handler: index.handler
    memorySize: 32768
    timeout: 600
    cpu: 8
    diskSize: 10240
    url:
      system_url: https://xxx.cn-hangzhou.fcapp.run
      system_intranet_url: https://xxx.cn-hangzhou-vpc.fcapp.run
      custom_domain:
        - domain: http://sd.fc-stable-diffusion-plus.xxxxx.cn-hangzhou.fc.devsapp.net
    triggers:
      - type: http
        name: defaultTrigger

Access URLs

Admin UI:

http://admin.fc-stable-diffusion-plus.xxxx.cn-hangzhou.fc.devsapp.net

Stable Diffusion UI:

http://sd.fc-stable-diffusion-plus.xxxxx.cn-hangzhou.fc.devsapp.net

Upload Model

Two methods are provided:

Method 1 – Visual Admin Interface

Visit the admin URL, log in, open the file manager, set the path to /mnt/auto/sd, and upload model files to models/Stable-diffusion/. Large files (>2‑3 GB) may be unstable.

Method 2 – NAS Command

Run the following command in the project root to upload the model:

s fc-nas-init nas upload -r <your-model-path> /mnt/auto/sd/models/Stable-diffusion/

The upload may take around 30 minutes.

Other assets such as ControlNet or extensions can be uploaded similarly, adjusting the NAS path accordingly.

Page Preview

After deployment, open the Stable Diffusion UI URL; the first cold start may require additional loading time.

Text‑to‑Image Example

Image‑to‑Image Example

Additional Notes

Alibaba Cloud provides free Serverless Function Compute resources for this experience. Users can explore AI image generation and participate in community activities.

Related Links

NAS: https://www.aliyun.com/product/nas?spm=5176

Function Compute: https://www.aliyun.com/product/fc?spm=5176.devs

Container Registry ACR: https://www.aliyun.com/product/acr?spm=5176.28055625.J_3207526240.121.1d22154aWn0gl1&scm=20140722.M_4776670._.V_1

Serverless Devs: https://docs.serverless-devs.com/serverless-devs/quick_start

Configure Alibaba Cloud credentials: https://docs.serverless-devs.com/serverless-devs/command/config#config-add-%E5%91%BD%E4%BB%A4

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ServerlessStable DiffusionAI deploymentAlibaba CloudFunction ComputeNASServerless Devs
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.