🖥️ Triton Inference Server

데이터 엔지니어 · AI 엔지니어를 위한 핵심 요약

#nvidia #inference #multi-framework #MLOps 2026.03

1. Triton Inference Server란?

NVIDIA Triton Inference Server는 프로덕션 환경에서 멀티 프레임워크 모델을 고성능으로 serving 하기 위한 오픈소스 추론 서버입니다. 하나의 서버에서 TensorRT, ONNX Runtime, PyTorch, TensorFlow, custom backend 등 다양한 포맷의 모델을 동시에 호스팅할 수 있습니다.

⚡ 고성능 추론

Dynamic batching, concurrent model execution, GPU 최적화로 최대 처리량 달성.

🔀 멀티 프레임워크

TensorRT, ONNX, PyTorch, TensorFlow, custom backend 등 동시 서빙.

📦 프로덕션 레디

모델 버저닝, health check, metrics (Prometheus), gRPC/REST, 동적 로딩 지원.

2. 왜 써야 하는가?

기존 추론 서빙 방식(TF Serving, TorchServe, 직접 FastAPI 등)과 비교한 Triton의 장점:

항목 Triton Inference Server TF Serving / TorchServe FastAPI (직접 구현)
멀티 프레임워크 ✅ 하나의 서버로 통합 ❌ 각 프레임워크 전용 ❌ 수동 통합 필요
Dynamic batching ✅ 내장, 지연시간 조절 가능 ✅ 제한적 ❌ 직접 구현
GPU 공유 & 최적화 ✅ MPS, concurrent execution △ 일부 지원 ❌ 복잡
모델 버저닝 ✅ Built-in ✅ Built-in ❌ 수동
모니터링 ✅ Prometheus metrics △ 제한적 ❌ 추가 개발
프로토콜 gRPC / HTTP/REST gRPC / REST 주로 REST
💡 결론: 멀티 프레임워크 환경, 고성능 추론, 운영 효율이 중요하다면 Triton이 가장 강력한 선택입니다.

3. 핵심 개념

아래는 Triton의 기본 아키텍처를 단순화한 ASCII 다이어그램입니다.

┌─────────────────────────────────────────────────────┐ │ Client (gRPC / HTTP) │ └────────────────────────┬────────────────────────────┘ │ ┌────────────────────────▼────────────────────────────┐ │ Triton Inference Server │ │ ┌────────────────────────────────────────────────┐ │ │ │ Scheduler / Model Manager │ │ │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ │ │ │ Model A │ │ Model B │ │ Model C │ │ │ │ │ │ (ONNX) │ │ (TensorRT)│ │ (PyTorch) │ │ │ │ │ │ inst x 2 │ │ inst x 1 │ │ inst x 2 │ │ │ │ │ └──────────┘ └──────────┘ └──────────┘ │ │ │ └────────────────────────────────────────────────┘ │ │ ┌────────────────────────────────────────────────┐ │ │ │ Backend: ONNX Runtime / TensorRT / Python │ │ │ └────────────────────────────────────────────────┘ │ │ ┌────────────────────────────────────────────────┐ │ │ │ GPU (CUDA) / CPU (OpenVINO) │ │ │ └────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────┘

4. 퀵스타트

4.1 설치 (Docker)

# NGC에서 최신 이미지 pull
docker pull nvcr.io/nvidia/tritonserver:23.12-py3

# GPU 사용 시 --gpus all 옵션
docker run --rm --gpus all -p 8000:8000 -p 8001:8001 -p 8002:8002 \
  -v /path/to/model_repository:/models \
  nvcr.io/nvidia/tritonserver:23.12-py3 \
  tritonserver --model-repository=/models

4.2 Model Repository 구조

최소한의 config.pbtxt 예제 (simple ONNX 모델):

model_repository/
└── densenet_onnx/
    ├── config.pbtxt
    └── 1/
        └── model.onnx
# config.pbtxt
name: "densenet_onnx"
backend: "onnxruntime"
max_batch_size: 32
input [
  {
    name: "data_0"
    data_type: TYPE_FP32
    dims: [3, 224, 224]
  }
]
output [
  {
    name: "prob_1"
    data_type: TYPE_FP32
    dims: [1000]
  }
]

4.3 Python 클라이언트 예제

import tritonclient.grpc as grpcclient
import numpy as np

# gRPC 클라이언트 생성
client = grpcclient.InferenceServerClient(url="localhost:8001")

# 입력 데이터 준비 (batch_size=1)
input_data = np.random.randn(1, 3, 224, 224).astype(np.float32)

# Triton InferInput 객체 생성
infer_input = grpcclient.InferInput("data_0", input_data.shape, "FP32")
infer_input.set_data_from_numpy(input_data)

# 추론 요청
result = client.infer(model_name="densenet_onnx", inputs=[infer_input])

# 결과 확인
output = result.as_numpy("prob_1")
print("Output shape:", output.shape)
print("Top-5:", np.argsort(output[0])[-5:][::-1])
✅ Tip: Triton은 기본적으로 HTTP 8000, gRPC 8001, Metrics 8002 포트를 사용합니다.

5. 핵심 설정 레퍼런스

config.pbtxt에서 자주 사용되는 설정 항목:

설정 키 설명 예시 값
name 모델 이름 (repository 디렉토리명과 일치) "my_model"
backend 사용할 backend (tensorrt, onnxruntime, pytorch, python 등) "onnxruntime"
max_batch_size 최대 배치 크기 (0=배치 미지원) 32
dynamic_batching 동적 배칭 활성화 및 옵션 preferred_batch_size: [4,8]
instance_group 모델 인스턴스 수 및 GPU 할당 count: 2, kind: KIND_GPU
input / output 텐서 이름, 데이터 타입, 차원 name, data_type, dims
version_policy 모델 버전 관리 (latest, specific, all) latest: { num_versions: 1 }

6. 실무 팁 & 트러블슈팅

⚠️ 문제 #1: "CUDA out of memory"
해결: instance_group의 count를 줄이거나, max_batch_size를 낮추고, GPU 메모리 모니터링으로 적정값 찾기.
⚠️ 문제 #2: Dynamic batching 적용 후 latency 급증
해결: dynamic_batching에 max_queue_delay_microseconds를 설정하여 최대 대기 시간 제한.
⚠️ 문제 #3: 모델 로드 실패 (config.pbtxt 오류)
해결: tritonserver --strict-model-config=false로 자동 설정 시도. 또는 model-analyzer로 config 검증.
💡 실무 팁:

7. 참고 자료