Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

stable-diffusion-server

> 编程语言
Open source

Deploy Your Own Stable Diffusion Service

200 stars0 likes1 views
WebsiteGitHub

About

Deploy Your Own Stable Diffusion Service

⚠️ Important Notice

This project is deprecated. To run and deploy the latest Stable Diffusion models, see the BentoDiffusion repo.

Serving Stable Diffusion with BentoML

Stable Diffusion is an open-source text-to-image model released by stability.ai. It enables you to generate creative arts from natural language prompts in just seconds. Follow the steps in this repository to create a production-ready Stable Diffusion service with BentoML and deploy it to AWS EC2.

Prepare the Environment

If you don't wish to build the bento from scratch, feel free to download one of the pre-built bentos.

Clone repository and install dependencies:

bash
git clone https://github.com/bentoml/stable-diffusion-bentoml.git && cd stable-diffusion-bentoml
python3 -m venv venv && . venv/bin/activate
pip install -U pip
pip install -r requirements.txt

Environment is ready!

Create the Stable Diffusion Bento

Here you can choose to either download pre-built Stable Diffusion bentos or build bentos from the Stable Diffusion models.

Download Pre-built Stable Diffusion Bentos

  • Download fp32 bento (for CPU or GPU with more than 10GB VRAM)

    bash
    curl -O https://s3.us-west-2.amazonaws.com/bentoml.com/stable_diffusion_bentoml/sd_fp32.bento && bentoml import ./sd_fp32.bento
  • Download fp16 bento (for GPU with less than 10GB VRAM)

    bash
    curl -O https://s3.us-west-2.amazonaws.com/bentoml.com/stable_diffusion_bentoml/sd_fp16.bento && bentoml import ./sd_fp16.bento

The Stable Diffusion bento is imported. You can advance to the "Deploy the Stable Diffusion Bento to EC2" section.

Build from Stable Diffusion Models

Choose a Stable Diffusion model

  • fp32 (for CPU or GPU with more than 10GB VRAM)

    bash
    cd fp32/
  • fp16 (for GPU with less than 10GB VRAM)

    bash
    cd fp16/

Download the Stable Diffusion model

  • For fp32 model:

    bash
    # if tar and gzip is availabe
    curl https://s3.us-west-2.amazonaws.com/bentoml.com/stable_diffusion_bentoml/sd_model_v1_4.tgz | tar zxf - -C models/
    
    # or if unzip is availabe
    curl -O https://s3.us-west-2.amazonaws.com/bentoml.com/stable_diffusion_bentoml/sd_model_v1_4.zip && unzip -d models/ sd_model_v1_4.zip
  • For fp16 model:

    bash
    # if tar and gzip is availabe
    curl https://s3.us-west-2.amazonaws.com/bentoml.com/stable_diffusion_bentoml/sd_model_v1_4_fp16.tgz | tar zxf - -C models/
    
    # or if unzip is availabe
    curl -O https://s3.us-west-2.amazonaws.com/bentoml.com/stable_diffusion_bentoml/sd_model_v1_4_fp16.zip && unzip -d models/ sd_model_v1_4_fp16.zip

Run and test the BentoML service:

  • Bring up the BentoML service with the following command.

    bash
    BENTOML_CONFIG=configuration.yaml bentoml serve service:svc --production
  • Then you can run one of the scripts to test the service.

    bash
    ../txt2img_test.sh
    ../img2img_test.sh

Build a bento:

…

The Stable Diffusion bento has been built! You can advance to the "Deploy the Stable Diffusion Bento to EC2" section.

Deploy the Stable Diffusion Bento to EC2

We will be using bentoctl to deploy the bento to EC2. bentoctl helps deploy your bentos into any cloud platform easily. Install the AWS EC2 operator to generate and apply Terraform files to EC2.

bentoctl operator install aws-ec2

The deployment has already been configured for you in the deployment_config.yaml file. By default bentoctl is configured to deploy the model on a g4dn.xlarge instance with Deep Learning AMI GPU PyTorch 1.12.0 (Ubuntu 20.04) AMI on us-west-1.

Note: This default configuration only works in the us-west-1 region. Choose the corresponding AMI Id in your region from AWS AMI Catalog to deploy to your desired region.

Generate the Terraform files.

bash
# In the /bentoctl directory
bentoctl generate -f deployment_config.yaml

✨ generated template files.
  - ./main.tf
  - ./bentoctl.tfvars

Build the Docker image and push to AWS ECR.

bash
bentoctl build -b stable_diffusion_fp32:latest -f deployment_config.yaml

 Image pushed!
✨ generated template files.
  - ./bentoctl.tfvars
  - ./startup_script.sh
  
There is also an experimental command that you can use.
To create the resources specifed run this after the build command.
$ bentoctl apply

To cleanup all the resources created and delete the registry run
$ bentoctl destroy

Apply the Terraform files to deploy to AWS EC2. Head over to the endpoint URL displayed at the end and you can see your Stable Diffusion service is up and running. Run some test prompts to make sure everything is working.

bash
bentoctl apply -f deployment_config.yaml

Apply complete! Resources: 2 added, 0 changed, 0 destroyed.

Outputs:

ec2_instance_status = "running"
endpoint = "http://53.183.151.211"

Finally, delete the deployment if the Stable Diffusion BentoML service is no longer needed.

bash
bentoctl destroy -f deployment_config.yaml

Issues· 5 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Pythonstable-diffusion

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言