Triton Inference Server
Background: where serving fits in an ML pipeline
Section titled “Background: where serving fits in an ML pipeline”This post is a 2021 record of validating model serving with an inference server on Kubernetes. First, here is where serving sits in an ML pipeline.
| Stage | What it does |
|---|---|
| Data Prep | Ingestion, exploratory data analysis (EDA), transformation, validation, and splitting into training, validation, and test sets |
| Model Creation | Training and validating the model, then training at scale on more data and GPUs with hyperparameter tuning |
| Roll out | Deploying to production, serving, monitoring accuracy and latency, and logging requests |
Serving is the stage that exposes a deployed model as a service. It splits into real-time (online) serving, which answers each request directly, and batch serving, which processes accumulated data in bulk. Triton in this post covers real-time serving; declaring serving through a Kubernetes CRD continues in the KFServing record.
Introduction
Section titled “Introduction”Triton Inference Server is a cloud and edge inference platform optimized for both CPU and GPU workloads. It supports HTTP/REST and gRPC, so remote clients can submit inference requests to any model that the server manages.
- Features
- Support for multiple deep-learning frameworks
- Concurrent model execution
- Dynamic batching
- KFServing-compatible protocol support
This post is less about exhaustively reviewing Triton’s feature set and more about validating how to deploy and test Triton in a Kubernetes environment. It also serves as groundwork for model serving with KFServing and for testing InferenceService resources.
Architecture
Section titled “Architecture”On Kubernetes, Triton is usually deployed as a straightforward Deployment and Service pair, but internally it is organized around the following components.
-
Model Repository
- A filesystem-based repository that stores models for Triton inference. It can be backed by mounted volumes or object storage.
- When starting Triton Server, point
--model-storeat the repository directory.
-
Client Request Scheduling / Routing
- Inference requests can arrive over HTTP/REST, gRPC, or the C API.
- Requests are internally routed to a scheduler for each model.
- Triton applies the scheduling and execution logic associated with each model loaded from the model repository.
-
Framework Backends
- Requests are dispatched to the backend that matches the model framework.
- The backend performs inference and returns the result.
-
Monitoring
- Triton exposes readiness, liveness, throughput, and latency metrics that can be integrated with Kubernetes monitoring.
-
Triton High-Level Architecture
Source: Triton Inference Server docs, Architecture, NVIDIA Corporation, BSD-3-Clause
Triton Inference Server Github Repository https://github.com/triton-inference-server/server See Triton Inference Server Architecture https://github.com/triton-inference-server/server/blob/main/docs/user_guide/architecture.md
Kubernetes Deploy
Section titled “Kubernetes Deploy”A Helm chart is provided for deploying Triton to AWS EKS. The official guide still mentions Tiller, but this setup was installed with Helm v3 without using that component. By default Triton runs as a Deployment, and high availability is handled by increasing the replica count.
- Work order
- Create an Amazon EKS cluster
- Configure an Amazon S3 model repository
- Deploy the
triton-inference-serverHelm chart - Deploy the
prometheus-operatorHelm chart for monitoring - Configure the Triton SDK client and run inference tests
Triton Inference Server AWS Deploy Guide https://github.com/triton-inference-server/server/tree/main/deploy/aws Triton Quick Start Guide https://github.com/triton-inference-server/server/blob/main/docs/getting_started/quickstart.md
Deploying the tritonserver helm chart
Section titled “Deploying the tritonserver helm chart”- Map the AWS Access Key for accessing S3 in values.yaml
- Modify imageName, modelRepositoryPath, cpu, etc.
- Create the Service as a LoadBalancer, creating an Amazon Classic Load Balancer
replicaCount: 1
service: type: LoadBalancer
image: imageName: nvcr.io/nvidia/tritonserver:21.04-py3 pullPolicy: IfNotPresent modelRepositoryPath: s3://kloudbank-triton-inference-server-repository/model_repository # numGpus: 1 numCpus: 1
secret: ...- result
$ kubectl get all -n tritonNAME READY STATUS RESTARTS AGEpod/kloudbank-triton-inference-server-xxxxxxxxxx-xxxxx 1/1 Running 0 39m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEservice/kloudbank-triton-inference-server LoadBalancer 10.0.0.35 <External-IP> 8000:31422/TCP,8001:31024/TCP,8002:30129/TCP 3h24mservice/kloudbank-triton-inference-server-metrics ClusterIP 10.0.0.36 <none> 8080/TCP 3h24m
NAME READY UP-TO-DATE AVAILABLE AGEdeployment.apps/kloudbank-triton-inference-server 1/1 1 1 3h24m
NAME DESIRED CURRENT READY AGEreplicaset.apps/kloudbank-triton-inference-server-xxxxxxxxxx 1 1 1 3h24m- logs
# Framework BackendI0526 03:39:25.498911 1 server.cc:543]+-------------+-----------------------------------------------------------------+--------+| Backend | Path | Config |+-------------+-----------------------------------------------------------------+--------+| tensorrt | <built-in> | {} || pytorch | /opt/tritonserver/backends/pytorch/libtriton_pytorch.so | {} || tensorflow | /opt/tritonserver/backends/tensorflow1/libtriton_tensorflow1.so | {} || onnxruntime | /opt/tritonserver/backends/onnxruntime/libtriton_onnxruntime.so | {} || openvino | /opt/tritonserver/backends/openvino/libtriton_openvino.so | {} |+-------------+-----------------------------------------------------------------+--------+
# load the Model from the Model RepositoryI0526 03:39:25.498991 1 server.cc:586]+----------------------+---------+--------+| Model | Version | Status |+----------------------+---------+--------+| densenet_onnx | 1 | READY || inception_graphdef | 1 | READY || simple | 1 | READY || simple_dyna_sequence | 1 | READY || simple_identity | 1 | READY || simple_int8 | 1 | READY || simple_sequence | 1 | READY || simple_string | 1 | READY |+----------------------+---------+--------+
...
# default Service Port (HTTP, GRPC, Metric)I0526 03:39:25.500218 1 grpc_server.cc:4028] Started GRPCInferenceService at 0.0.0.0:8001I0526 03:39:25.500467 1 http_server.cc:2761] Started HTTPService at 0.0.0.0:8000I0526 03:39:25.541702 1 http_server.cc:2780] Started Metrics Service at 0.0.0.0:8002
...Inference Request Monitoring
Section titled “Inference Request Monitoring”Deploy stable/prometheus to monitor inference requests. When installing it, set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false so Prometheus can discover and scrape Triton’s metrics.
- Grafana dashboard provided by Triton
- Inference-processing metrics are tracked separately for each model in the repository (eight models in this example).
- A scheduling queue is also exposed per model.

See grafana dashboard.json https://github.com/triton-inference-server/server/blob/main/deploy/aws/dashboard.json
SDK Client Test
Section titled “SDK Client Test”Triton can load and serve models only when they follow the required repository directory structure. In this example, an Amazon S3 model repository was populated with the sample models and then used to test inference requests against the Triton server running on EKS.
See triton sample model https://github.com/triton-inference-server/server/tree/main/docs/examples/model_repository
- Run the triton-inference-server SDK Docker container
docker pull nvcr.io/nvidia/tritonserver:21.04-py3-sdkdocker run -it --rm --net=host nvcr.io/nvidia/tritonserver:21.04-py3-sdk- Result of entering the SDK container and running
image_clientto test an HTTP request
# run densenet_onnxroot@docker-desktop:/workspace# /workspace/install/bin/image_client -m densenet_onnx -c 3 -s INCEPTION -u <External-IP>:8000 /workspace/images/mug.jpgRequest 0, batch size 1Image '/workspace/images/mug.jpg': 15.349564 (504) = COFFEE MUG 13.227464 (968) = CUP 10.424892 (505) = COFFEEPOT
# run inception_graphdefroot@docker-desktop:/workspace# /workspace/install/bin/image_client -m inception_graphdef -c 3 -s INCEPTION -u <External-IP>:8000 /workspace/images/mug.jpgRequest 0, batch size 1Image '/workspace/images/mug.jpg': 0.754047 (505) = COFFEE MUG 0.157066 (969) = CUP 0.002878 (968) = ESPRESSO- Monitoring results for each processed model
