Deploy Stable Diffusion on Alibaba Cloud Serverless in Minutes
This guide walks you through registering for Alibaba Cloud, enabling Function Compute and NAS, creating a Stable Diffusion application from a template, configuring the admin console, uploading the model, optionally building a custom Docker image, and troubleshooting common issues, all with step‑by‑step instructions and code examples.
Prerequisites
Register and log in to an Alibaba Cloud account.
Enable Function Compute.
Enable NAS file storage.
Quick Start
Open the Application Center at https://account.aliyun.com/login/login.htm?oauth_callback=https%3A%2F%2Ffcnext.console.aliyun.com%2Fapplications&lang=zh.
Create an application from the template: AI Digital Painting → Stable‑Diffusion custom template → Create.
Fill the form: select **Direct Deploy**, choose the **Hangzhou** region, and paste the prepared container image reference.
Click **Create**. Deployment takes about 5‑10 minutes; logs can be viewed if needed.
Configure Management Console
After deployment you receive two domain names – one for the Stable Diffusion service and one for the admin console (powered by kod‑box). Log in to the admin console, set a username and password.
Upload Model
In the console navigate to /mnt/auto/sd/models/Stable-diffusion/ and click “Upload → Offline Download”. Provide a model URL, for example:
https://huggingface.co/runwayml/stable-diffusion-inpainting/resolve/main/sd-v1-5-inpainting.ckptThe file is downloaded to NAS (typically 5‑15 minutes). If the model originates from HuggingFace, rename the file extension as required.
Custom Docker Image (Optional)
You can build a custom Docker image based on the repository:
https://github.com/AbdBarho/stable-diffusion-webui-docker/tree/master/services/AUTOMATIC1111
Replace the default entrypoint.sh with the script below and push the image to your registry. Then update the image reference in the deployment steps (ensure the region matches).
#!/bin/bash
set -Eeuo pipefail
# Create script mount point
mkdir -p /mnt/auto/sd/config/auto/scripts/
# Mount scripts individually
find "${ROOT}/scripts/" -maxdepth 1 -type l -delete
cp -vrfTs /mnt/auto/sd/config/auto/scripts/ "${ROOT}/scripts/"
cp -n /docker/config.json /mnt/auto/sd/config/auto/config.json
jq '. * input' /mnt/auto/sd/config/auto/config.json /docker/config.json | sponge /mnt/auto/sd/config/auto/config.json
if [ ! -f /mnt/auto/sd/config/auto/ui-config.json ]; then
echo '{}' >/mnt/auto/sd/config/auto/ui-config.json
fi
declare -A MOUNTS
MOUNTS["/root/.cache"]="/mnt/auto/sd/.cache"
MOUNTS["${ROOT}/models"]="/mnt/auto/sd/models"
MOUNTS["${ROOT}/embeddings"]="/mnt/auto/sd/embeddings"
MOUNTS["${ROOT}/config.json"]="/mnt/auto/sd/config/auto/config.json"
MOUNTS["${ROOT}/ui-config.json"]="/mnt/auto/sd/config/auto/ui-config.json"
MOUNTS["${ROOT}/extensions"]="/mnt/auto/sd/config/auto/extensions"
MOUNTS["${ROOT}/outputs"]="/mnt/auto/sd/config/auto/outputs"
MOUNTS["${ROOT}/extensions-builtin"]="/mnt/auto/sd/extensions-builtin"
MOUNTS["${ROOT}/configs"]="/mnt/auto/sd/configs"
MOUNTS["${ROOT}/localizations"]="/mnt/auto/sd/localizations"
# Extra hacks
MOUNTS["${ROOT}/repositories/CodeFormer/weights/facelib"]="/mnt/auto/sd/.cache"
for to_path in "${!MOUNTS[@]}"; do
from_path="${MOUNTS[${to_path}]}"
rm -rf "${to_path}"
[ -d "$from_path" ] || mkdir -vp "$from_path"
mkdir -vp "$(dirname "${to_path}")"
ln -sT "$from_path" "$to_path"
echo "Mounted $(basename "$from_path")"
done
if [ -f "/mnt/auto/sd/config/auto/startup.sh" ]; then
pushd ${ROOT}
. /mnt/auto/sd/config/auto/startup.sh
popd
fi
exec "$@"FAQ
Model download fails : Verify the file name and extension.
Plugins cannot be installed online : Download plugins locally and upload them to the extensions directory, or customize the Docker image to allow URL‑based installation.
Accessing the Stable Diffusion API : Enable the --api flag in the custom image and visit /docs for the API specification.
Cost : The service uses Function Compute and NAS; free quotas are available for new users. Purchase resource packages if needed.
More flexible customization : Map the entire webui directory to NAS for easier source modifications.
License compliance : Observe the open‑source licenses of all components used.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
