NVIDIA Triton 推理服务器
Triton Inference Server 支持 TensorRT、ONNX Runtime、PyTorch、Python 等多种后端,提供统一 HTTP/gRPC 接口、动态批处理和模型编排。适合多模型、多框架的生产推理。
启动服务:
docker run --gpus all --rm \
-p 8000:8000 -p 8001:8001 -p 8002:8002 \
-v $(pwd)/models:/models \
nvcr.io/nvidia/tritonserver:24.10-py3 \
tritonserver --model-repository=/models
查看模型状态:
curl http://localhost:8000/v2/models
curl http://localhost:8000/v2/models/resnet50/config
推理请求:
curl -X POST http://localhost:8000/v2/models/resnet50/infer \
-H 'Content-Type: application/json' \
-d '{"inputs":[{"name":"input","shape":[1,3,224,224],"datatype":"FP32","data":[...]}]}'
模型配置 config.pbtxt:
name: "resnet50"
platform: "tensorrt_plan"
max_batch_size: 8
input [
{ name: "input" data_type: TYPE_FP32 dims: [3, 224, 224] }
]
output [
{ name: "output" data_type: TYPE_FP32 dims: [1000] }
]
启用动态批处理:
dynamic_batching {
preferred_batch_size: [4, 8]
max_queue_delay_microseconds: 1000
}
<model>/<version>/model.* 规范。config.pbtxt 的输入输出名称、维度和数据类型与模型不一致。max_queue_delay。