需要 Python≥3.9;本地运行示例还需另装 torch 和 transformers;bentoml serve 默认监听 3000 端口;containerize 前需确保 Docker 已运行;框架默认收集匿名使用数据,可用 --do-not-track 或 BENTOML_DO_NOT_TRACK=True 关闭。
BentoML
bentomlApache-2.0活跃维护把训练好的模型快速封装成推理 API 和任务队列,支持 LLM 应用与多模型流水线,省去自己搭服务框架的麻烦。
The easiest way to serve AI apps and models - Build Model Inference APIs, Job queues, LLM apps, Multi-model pipelines, and more!
pip install -U bentoml
bentoml serveREADME 未给出具体显存或 GPU 型号要求;示例代码在 torch.cuda.is_available() 为真时用 CUDA,否则回退到 CPU 运行。
把任意 AI 模型推理脚本几行代码变成 REST API 服务的 Python 框架
把训练好的模型快速封装成推理 API 和任务队列,支持 LLM 应用与多模型流水线,省去自己搭服务框架的麻烦。
核心能力
- 用 Python 类型注解把推理函数声明为 REST API
- 用配置文件管理依赖与模型版本并自动生成 Docker 镜像
- 内置动态批处理、模型并行与多模型推理图编排
- 支持任意 ML 框架、模态与推理运行时
- 本地调试后可直接部署到 Docker 或 Kubernetes
容易踩的坑
- v1.4.40最新正式版2026-10-23 · 2026-10-23 19:51 UTC
Security: eMudhra intermediate CA compromise
- `certifi>=2026.10.19` is now required. It drops trust in the compromised eMudhra/emSign CAs.
- Generated Dockerfiles and local `bentoml build` install `uv==0.13.4` with `--require-hashes` whenever uv is missing or older (uv < 0.13.4 bundles the compromised CAs). pip 26.2.2 is used where supported. (#5757)
Action for users: run `bentoml build` again with 1.4.40, then redeploy, so your bento image picks up the fixed certifi and uv.
Also in this release
- Agent skills for creating BentoML projects and for deploying to Kubernetes and EC2 (#5705, #5683)
- Windows tar symlink extraction and fastai CI dependency resolution fix (#5689)
- Docs and CI updates (#5710, #5715, #5741, #5702, #5758, #5759, #5760)
Full Changelog: https://github.com/bentoml/BentoML/compare/v1.4.39...v1.4.40
- v1.4.392026-05-07 · 2026-05-07 10:37 UTC
查看更新说明
What's Changed
- ci: pre-commit autoupdate [skip ci] by @pre-commit-ci[bot] in https://github.com/bentoml/BentoML/pull/5593
- fix: prevent following symlinks when copying files in BentoStore by @frostming in https://github.com/bentoml/BentoML/pull/5598
- fix: add sharing=locked to BuildKit cache mounts for multi-arch builds by @lawrence3699 in https://github.com/bentoml/BentoML/pull/5597
- fix: enhance Dockerfile generation by normalizing base image lines and adding tests by @frostming in https://github.com/bentoml/BentoML/pull/5603
- fix: defer prometheus_client import in bentoml.metrics to fix histogram collection in multiprocess mode by @ramkrishs in https://github.com/bentoml/BentoML/pull/5602
- ci: pre-commit autoupdate [skip ci] by @pre-commit-ci[bot] in https://github.com/bentoml/BentoML/pull/5605
- fix: handle string input in FileSchema by encoding to UTF-8 by @frostming in https://github.com/bentoml/BentoML/pull/5606
New Contributors
- @lawrence3699 made their first contribution in https://github.com/bentoml/BentoML/pull/5597
- @ramkrishs made their first contribution in https://github.com/bentoml/BentoML/pull/5602
Full Changelog: https://github.com/bentoml/BentoML/compare/v1.4.38...v1.4.39
- v1.4.382026-04-02 · 2026-04-02 06:12 UTC
查看更新说明
What's Changed
- feat: native support for src-layout projects by @VedantMadane in https://github.com/bentoml/BentoML/pull/5555
- fix: switch to SandboxedEnvironment and remove unused Jinja2 extensions by @frostming in https://github.com/bentoml/BentoML/pull/5591
- fix: use correct NVIDIA CUDA base images for debian distro by @mattmorganpdx in https://github.com/bentoml/BentoML/pull/5590
New Contributors
- @mattmorganpdx made their first contribution in https://github.com/bentoml/BentoML/pull/5590
Full Changelog: https://github.com/bentoml/BentoML/compare/v1.4.37...v1.4.38
- v1.4.372026-03-25 · 2026-03-25 01:20 UTC
查看更新说明
What's Changed
- docs: Update slack to forum link by @Sherlock113 in https://github.com/bentoml/BentoML/pull/5567
- fix: correctly load
bentoml.models.HuggingFaceModelin container by @nickthegroot in https://github.com/bentoml/BentoML/pull/5582 - chore(deps): bump docker/setup-qemu-action from 3 to 4 by @dependabot[bot] in https://github.com/bentoml/BentoML/pull/5564
- chore(deps): bump marocchino/sticky-pull-request-comment from 2 to 3 by @dependabot[bot] in https://github.com/bentoml/BentoML/pull/5571
- chore(deps): bump docker/setup-buildx-action from 3 to 4 by @dependabot[bot] in https://github.com/bentoml/BentoML/pull/5565
- fix: resolve SQLite 'database is locked' errors under high concurrency by @VedantMadane in https://github.com/bentoml/BentoML/pull/5558
- fix: shell quote system package names in Dockerfile templates and image commands by @frostming in https://github.com/bentoml/BentoML/pull/5583
- fix: reorder histogram samples in multiprocess prometheus output by @saivedant169 in https://github.com/bentoml/BentoML/pull/5570
New Contributors
- @nickthegroot made their first contribution in https://github.com/bentoml/BentoML/pull/5582
- @saivedant169 made their first contribution in https://github.com/bentoml/BentoML/pull/5570
Full Changelog: https://github.com/bentoml/BentoML/compare/v1.4.36...v1.4.37
- v1.4.362026-03-06 · 2026-03-06 04:25 UTC
查看更新说明
What's Changed
- fix: correct typo 'seperators' to 'separators' by @thecaptain789 in https://github.com/bentoml/BentoML/pull/5546
- Reapply "feat: new image API: build_include" (#5531) by @frostming in https://github.com/bentoml/BentoML/pull/5539
- fix: resolve AnyIO NoEventLoopError when calling sync API from async API by @paipeline in https://github.com/bentoml/BentoML/pull/5550
- fix: Set SQLite busy_timeout and WAL mode to prevent 'database is locked' under concurrency by @VedantMadane in https://github.com/bentoml/BentoML/pull/5551
- Fix memory leak in readiness checks with remote dependencies by @paipeline in https://github.com/bentoml/BentoML/pull/5553
- fix: validate symlink targets in safe_extract_tarfile by @q1uf3ng in https://github.com/bentoml/BentoML/pull/5548
- Revert "fix: resolve AnyIO NoEventLoopError when calling sync API from async API" by @frostming in https://github.com/bentoml/BentoML/pull/5554
- chore: update AWS BYOC doc to v10 by @sauyon in https://github.com/bentoml/BentoML/pull/5559
- chore(deps): bump actions/download-artifact from 7 to 8 by @dependabot[bot] in https://github.com/bentoml/BentoML/pull/5561
- chore(deps): bump actions/upload-artifact from 6 to 7 by @dependabot[bot] in https://github.com/bentoml/BentoML/pull/5560
- ci: pre-commit autoupdate [skip ci] by @pre-commit-ci[bot] in https://github.com/bentoml/BentoML/pull/5562
New Contributors
- @thecaptain789 made their first contribution in https://github.com/bentoml/BentoML/pull/5546
- @paipeline made their first contribution in https://github.com/bentoml/BentoML/pull/5550
- @VedantMadane made their first contribution in https://github.com/bentoml/BentoML/pull/5551
- @q1uf3ng made their first contribution in https://github.com/bentoml/BentoML/pull/5548
Full Changelog: https://github.com/bentoml/BentoML/compare/v1.4.35...v1.4.36
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Unified Model Serving Framework
🍱 Build model inference APIs and multi-model serving systems with any open-source or custom AI models. 👉 Join our forum!
What is BentoML?
BentoML is a Python library for building online serving systems optimized for AI apps and model inference.
- 🍱 Easily build APIs for Any AI/ML Model. Turn any model inference script into a REST API server with just a few lines of code and standard Python type hints.
- 🐳 Docker Containers made simple. No more dependency hell! Manage your environments, dependencies and model versions with a simple config file. BentoML automatically generates Docker images, ensures reproducibility, and simplifies how you deploy to different environments.
- 🧭 Maximize CPU/GPU utilization. Build high performance inference APIs leveraging built-in serving optimization features like dynamic batching, model parallelism, multi-stage pipeline and multi-model inference-graph orchestration.
- 👩💻 Fully customizable. Easily implement your own APIs or task queues, with custom business logic, model inference and multi-model composition. Supports any ML framework, modality, and inference runtime.
- 🚀 Ready for Production. Develop, run and debug locally. Seamlessly deploy to production with Docker containers or Kubernetes.
Getting started
Install BentoML:
# Requires Python≥3.9
pip install -U bentoml
Define APIs in a service.py file.
import bentoml
@bentoml.service(
image=bentoml.images.Image(python_version="3.11").python_packages("torch", "transformers"),
)
class Summarization:
def __init__(self) -> None:
import torch
from transformers import pipeline
device = "cuda" if torch.cuda.is_available() else "cpu"
self.pipeline = pipeline('summarization', device=device)
@bentoml.api(batchable=True)
def summarize(self, texts: list[str]) -> list[str]:
results = self.pipeline(texts)
return [item['summary_text'] for item in results]
💻 Run locally
Install PyTorch and Transformers packages to your Python virtual environment.
pip install torch transformers # additional dependencies for local run
Run the service code locally (serving at http://localhost:3000 by default):
bentoml serve
You should expect to see the following output.
[INFO] [cli] Starting production HTTP BentoServer from "service:Summarization" listening on http://localhost:3000 (Press CTRL+C to quit)
[INFO] [entry_service:Summarization:1] Service Summarization initialized
Now you can run inference from your browser at http://localhost:3000 or with a Python script:
import bentoml
with bentoml.SyncHTTPClient('http://localhost:3000') as client:
summarized_text: str = client.summarize([bentoml.__doc__])[0]
print(f"Result: {summarized_text}")
🐳 Deploy using Docker
Run bentoml build to package necessary code, models, dependency configs into a Bento - the standardized deployable artifact in BentoML:
bentoml build
Ensure Docker is running. Generate a Docker container image for deployment:
bentoml containerize summarization:latest
Run the generated image:
docker run --rm -p 3000:3000 summarization:latest
Examples
- LLMs: Llama 3.2, Mistral, DeepSeek Distil, and more.
- Image Generation: Stable Diffusion 3 Medium, Stable Video Diffusion, Stable Diffusion XL Turbo, ControlNet, and LCM LoRAs.
- Embeddings: SentenceTransformers and ColPali
- Audio: ChatTTS, XTTS, WhisperX, Bark
- Computer Vision: YOLO and ResNet
- Advanced examples: Function calling, LangGraph, CrewAI
Check out the full list for more sample code and usage.
Advanced topics
- Model composition
- Workers and model parallelization
- Adaptive batching
- GPU inference
- Distributed serving systems
- Model loading and Model Store
- Observability
See Documentation for more tutorials and guides.
Community
Get involved and join our Community Forum 💬, where thousands of AI/ML engineers help each other, contribute to the project, and talk about building AI products.
To report a bug or suggest a feature request, use GitHub Issues.
Contributing
There are many ways to contribute to the project:
- Report bugs and "Thumbs up" on issues that are relevant to you.
- Investigate issues and review other developers' pull requests.
- Contribute code or documentation to the project by submitting a GitHub pull request.
- Check out the Contributing Guide and Development Guide to learn more.
- Share your feedback and discuss roadmap plans in our forum.
Thanks to all of our amazing contributors!
Usage tracking and feedback
The BentoML framework collects anonymous usage data that helps our community improve the product. Only BentoML's internal API calls are being reported. This excludes any sensitive information, such as user code, model data, model names, or stack traces. Here's the code used for usage tracking. You can opt-out of usage tracking by the --do-not-track CLI option:
bentoml [command] --do-not-track
Or by setting the environment variable:
export BENTOML_DO_NOT_TRACK=True