AI模型推理(6)——实战篇(进阶)

Triton

参考文档:

https://blog.csdn.net/chenxy02/article/details/130465393

深度学习部署神器——triton inference server入门教程指北 - 知乎 (zhihu.com)

简介

Triton是Nvidia官方推出的推理服务化框架(简单解释就是 加载你的模型变成别人可以请求的服务)。一开始叫 TensorRT serving,是专门针对TensorRT设计的服务器框架,后来支持了onnxruntime、pytorch、tensorflow等推理后端,变为了triton。

创建服务

我们可以跟官方文档 GitHub - triton-inference-server/server: The Triton Inference Server provides an optimized cloud and edge inferencing solution. 学习使用Triton。如下:

# Step 1: Create the example model repository
git clone -b r23.10 https://github.com/triton-inference-server/server.git
# 执行脚本, 拉取模型文件
cd server/docs/examples
./fetch_model.sh

# Step 2: Launch triton from the NGC Triton container
# 启动Triton容器,执行tritonserver(需指定模型仓库地址)
docker run --gpus=1 --rm --net=host -v ${PWD}/model_repository:/models nvcr.io/nvidia/tritonserver:23.10-py3 tritonserver --model-repository=/models

预期结果如下:

其中 http服务使用8000端口,grpc使用8001端口,检测接口(可用于监控服务的健康情况)使用8002

调用服务

# Step 3: Sending an Inference Request
# In a separate console, launch the image_client example from the NGC Triton SDK container
docker run -it --rm --net=host nvcr.io/nvidia/tritonserver:23.10-py3-sdk
/workspace/install/bin/image_client -m densenet_onnx -c 3 -s INCEPTION /workspace/images/mug.jpg

# Inference should return the following
Image '/workspace/images/mug.jpg':
    15.346230 (504) = COFFEE MUG
    13.224326 (968) = CUP
    10.422965 (505) = COFFEEPOT

# 也可以进入这里起的容器里的/workspace/install/python 执行(预期结果同上):
./image_client.py -m densenet_onnx -c 3 -s INCEPTION /workspace/images/mug.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值