云部署¶
BentoCloud 是一个推理管理平台和计算编排引擎,构建在 BentoML 开源服务框架之上。它提供了一个完整的堆栈,用于在任何云上使用任何模型构建快速且可扩展的 AI 系统。
为什么开发者喜爱 BentoCloud
灵活的 Pythonic API,用于构建推理 API、批量任务和复合 AI 系统
针对 ML/AI 工作负载重建的容器基础设施堆栈,实现极速冷启动
支持任何 ML 框架和推理运行时(vLLM、TensorRT、Triton 等)
涵盖开发、测试、部署、监控和 CI/CD 的精简工作流程
在我们的云或您自己的云中轻松访问各种 GPU,如 L4 和 A100
以下是将您的 AI 服务部署到 BentoCloud 的工作流程

登录 BentoCloud¶
访问 BentoML 网站注册。
安装 BentoML。
pip install bentoml
使用
bentoml cloud login
命令登录 BentoCloud。按照屏幕上的说明创建新的 API 令牌。$ bentoml cloud login ? How would you like to authenticate BentoML CLI? [Use arrows to move] > Create a new API token with a web browser Paste an existing API token
部署您的第一个模型¶
克隆Hello world 示例。
git clone https://github.com/bentoml/quickstart.git cd quickstart
从项目目录将其部署到 BentoCloud。您可以使用
-n
标志设置名称。bentoml deploy -n my-first-bento
注意
默认情况下,此命令会打包执行它的目录下所有文件。要排除特定文件或目录,请在
.bentoignore
文件中定义它们。示例输出
🍱 Built bento summarization:ngfnciv5g6nxonry Successfully pushed Bento "summarization:ngfnciv5g6nxonry" ✅ Created deployment "my-first-bento" in cluster "google-cloud-us-central-1" 💻 View Dashboard: https://demo.cloud.bentoml.com/deployments/my-first-bento
首次部署可能需要一到两分钟。请等待其完全就绪
✅ Deployment "my-first-bento" is ready: https://demo.cloud.bentoml.com/deployments/my-first-bento
在 BentoCloud 控制台中,导航到“部署”页面,然后点击您的部署。部署启动并运行后,您可以使用“Playground”选项卡上的“表单”部分与其交互。
调用部署端点¶
通过 CLI 获取部署 URL。如果您使用其他名称,请替换
my-first-bento
。bentoml deployment get my-first-bento -o json | jq ."endpoint_urls"
注意
确保已安装
jq
以处理 JSON 输出。创建一个BentoML 客户端来调用暴露的端点。将示例 URL 替换为您部署的 URL
import bentoml client = bentoml.SyncHTTPClient("https://my-first-bento-e3c1c7db.mt-guc1.bentoml.ai") result: str = client.summarize( text="Breaking News: In an astonishing turn of events, the small town of Willow Creek has been taken by storm as local resident Jerry Thompson's cat, Whiskers, performed what witnesses are calling a 'miraculous and gravity-defying leap.' Eyewitnesses report that Whiskers, an otherwise unremarkable tabby cat, jumped a record-breaking 20 feet into the air to catch a fly. The event, which took place in Thompson's backyard, is now being investigated by scientists for potential breaches in the laws of physics. Local authorities are considering a town festival to celebrate what is being hailed as 'The Leap of the Century.", ) print(result)
更新部署¶
要应用代码更改,请在本地修改代码,并通过运行以下命令更新 BentoCloud 上的部署
bentoml deployment update my-first-bento --bento ./project/directory
有关更多信息,请参阅管理部署。
配置扩缩容¶
副本数量默认为 1
。您可以更新允许扩缩容的最小和最大副本数
bentoml deployment update my-first-bento --scaling-min 0 --scaling-max 3
清理¶
要终止此部署,请在其详情页面的右上角点击“停止”,或者直接运行
bentoml deployment terminate my-first-bento
更多资源¶
如果您是 BentoCloud 的首次用户,建议您阅读以下文档以快速入门