推荐 Python 3.11,版本不符可能装不上依赖;首次启动会从 Hugging Face 拉取模型权重,需提前配好网络或缓存;服务默认监听 3000 端口,被占用需另行处理;部署到 BentoCloud 前需先 bentoml cloud login。
BentoDiffusion
bentomlApache-2.0活跃维护把 Stable Diffusion 等扩散模型用 BentoML 打包成可部署的推理服务,支持 LoRA 微调权重和 Kubernetes 部署,省去自己搭服务框架的麻烦。
BentoDiffusion: A collection of diffusion models served with BentoML
git clone https://github.com/bentoml/BentoDiffusion.git
cd BentoDiffusion/sdxl-turbo
pip install -r requirements.txt
bentoml serve本地测试推荐使用显存至少 12GB 的 Nvidia GPU;README 未说明是否支持纯 CPU 运行或其他 GPU 厂商。
用 BentoML 把 Stable Diffusion 系列模型自托管成 HTTP 服务的示例合集
把 Stable Diffusion 等扩散模型用 BentoML 打包成可部署的推理服务,支持 LoRA 微调权重和 Kubernetes 部署,省去自己搭服务框架的麻烦。
核心能力
- 按模型分子目录提供 SDXL Turbo、SD3、FLUX.1 等示例
- 用 BentoML Service 封装 txt2img 接口并暴露 Swagger UI
- 提供 curl 与 Python SyncHTTPClient 两种调用方式
- 一条 bentoml deploy 即可部署到 BentoCloud
- 可生成 OCI 镜像用于自有基础设施部署
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
This repository contains a series of BentoML example projects, demonstrating how to deploy different models in the Stable Diffusion (SD) family, which is specialized in generating and manipulating images or video clips based on text prompts.
See here for a full list of BentoML example projects.
The following guide uses SDXL Turbo as an example.
Prerequisites
If you want to test the Service locally, we recommend you use an Nvidia GPU with at least 12GB VRAM.
Install dependencies
git clone https://github.com/bentoml/BentoDiffusion.git
cd BentoDiffusion/sdxl-turbo
# Recommend Python 3.11
pip install -r requirements.txt
Run the BentoML Service
We have defined a BentoML Service in service.py. Run bentoml serve in your project directory to start the Service.
$ bentoml serve
2024-01-18T18:31:49+0800 [INFO] [cli] Starting production HTTP BentoServer from "service:SDXLTurboService" listening on http://localhost:3000 (Press CTRL+C to quit)
Loading pipeline components...: 100%
The server is now active at http://localhost:3000. You can interact with it using the Swagger UI or in other different ways.
CURL
curl -X 'POST' \
'http://localhost:3000/txt2img' \
-H 'accept: image/*' \
-H 'Content-Type: application/json' \
-d '{
"prompt": "A cinematic shot of a baby racoon wearing an intricate italian priest robe.",
"num_inference_steps": 1,
"guidance_scale": 0
}'
Python client
import bentoml
with bentoml.SyncHTTPClient("http://localhost:3000") as client:
result = client.txt2img(
prompt="A cinematic shot of a baby racoon wearing an intricate italian priest robe.",
num_inference_steps=1,
guidance_scale=0.0
)
For detailed explanations of the Service code, see Stable Diffusion XL Turbo.
Deploy to BentoCloud
After the Service is ready, you can deploy the application to BentoCloud for better management and scalability. Sign up if you haven't got a BentoCloud account.
Make sure you have logged in to BentoCloud.
bentoml cloud login
Deploy it to BentoCloud.
bentoml deploy
Once the application is up and running on BentoCloud, you can access it via the exposed URL.
Note: For custom deployment in your own infrastructure, use BentoML to generate an OCI-compliant image.
Choose another diffusion model
To deploy a different diffusion model, go to the corresponding subdirectories of this repository.