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