triton

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
}

易错点与排错