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!

v1.4.40发布于 2026-10-23 19:51 UTC8,935star +1 / 7 天1,062fork同步于 2026-11-10 11:31 UTC

怎么上手

由 README 提炼,执行前请确认
pip install -U bentoml
bentoml serve
硬件要求按 README 说明

README 未给出具体显存或 GPU 型号要求;示例代码在 torch.cuda.is_available() 为真时用 CUDA,否则回退到 CPU 运行。

有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

把任意 AI 模型推理脚本几行代码变成 REST API 服务的 Python 框架

把训练好的模型快速封装成推理 API 和任务队列,支持 LLM 应用与多模型流水线,省去自己搭服务框架的麻烦。

核心能力

  • 用 Python 类型注解把推理函数声明为 REST API
  • 用配置文件管理依赖与模型版本并自动生成 Docker 镜像
  • 内置动态批处理、模型并行与多模型推理图编排
  • 支持任意 ML 框架、模态与推理运行时
  • 本地调试后可直接部署到 Docker 或 Kubernetes

容易踩的坑

需要 Python≥3.9;本地运行示例还需另装 torch 和 transformers;bentoml serve 默认监听 3000 端口;containerize 前需确保 Docker 已运行;框架默认收集匿名使用数据,可用 --do-not-track 或 BENTOML_DO_NOT_TRACK=True 关闭。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.4.40
  1. 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

  2. v1.4.392026-05-07 · 2026-05-07 10:37 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/bentoml/BentoML/compare/v1.4.38...v1.4.39

  3. v1.4.382026-04-02 · 2026-04-02 06:12 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/bentoml/BentoML/compare/v1.4.37...v1.4.38

  4. v1.4.372026-03-25 · 2026-03-25 01:20 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/bentoml/BentoML/compare/v1.4.36...v1.4.37

  5. v1.4.362026-03-06 · 2026-03-06 04:25 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/bentoml/BentoML/compare/v1.4.35...v1.4.36

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Unified Model Serving Framework

    🍱 Build model inference APIs and multi-model serving systems with any open-source or custom AI models. 👉 Join our forum!

    License: Apache-2.0 Releases CI Twitter

    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

    Check out the full list for more sample code and usage.

    Advanced topics

    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:

    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
    

    License

    Apache License 2.0