Tensorrt

From mkurman/zorai · View interactive version

Tensorrt is an AI agent skill from the GitHub repository mkurman/zorai. NVIDIA TensorRT — deep learning inference optimizer. FP16/INT8/INT4 quantization, kernel auto-tuning, layer fusion, and dynamic shapes. Max throughput on NVIDIA GPUs for production inference.

How to use this skill

Skill file

Overview

TensorRT is NVIDIA's high-performance inference optimizer and runtime for deploying deep learning models on NVIDIA GPUs. Use it when you need lower latency, higher throughput, FP16/INT8 optimization, or production GPU serving from ONNX or TensorFlow/PyTorch exports.

When to Use

Use this skill when:

Install / Environment

TensorRT is usually installed via NVIDIA packages, Docker images, or NGC containers rather than plain pip.

Typical paths:

# Inside NVIDIA container ecosystems
# Use an NGC PyTorch or TensorRT container

# ONNX graph simplification often helps before conversion
uv pip install onnx onnxruntime onnxsim polygraphy

Fastest Common Workflow: ONNX -> TensorRT Engine

  1. Export model to ONNX.
  2. Validate ONNX with ONNX Runtime.
  3. Build TensorRT engine with trtexec.
  4. Benchmark latency/throughput.
  5. Integrate engine into app or Triton.

Export from PyTorch to ONNX

import torch

dummy = torch.randn(1, 3, 224, 224, device='cuda')
model.eval()

torch.onnx.export(
    model,
    dummy,
    'model.onnx',
    input_names=['input'],
    output_names=['logits'],
    dynamic_axes={'input': {0: 'batch'}, 'logits': {0: 'batch'}},
    opset_version=17,
)

Validate the ONNX model first

python - <<'PY'
import onnx
m = onnx.load('model.onnx')
onnx.checker.check_model(m)
print('ONNX OK')
PY

Build an FP16 engine

trtexec   --onnx=model.onnx   --saveEngine=model_fp16.plan   --fp16   --workspace=4096   --minShapes=input:1x3x224x224   --optShapes=input:8x3x224x224   --maxShapes=input:32x3x224x224

INT8 optimization

Use INT8 only when you have either:

trtexec   --onnx=model.onnx   --saveEngine=model_int8.plan   --int8   --fp16

Benchmarking

trtexec --loadEngine=model_fp16.plan --shapes=input:8x3x224x224

Check:

Triton deployment

Recommended production layout:

model_repository/
  my_model/
    1/
      model.plan
    config.pbtxt

Minimal config.pbtxt:

name: "my_model"
platform: "tensorrt_plan"
max_batch_size: 32
input [
  {
    name: "input"
    data_type: TYPE_FP32
    dims: [ 3, 224, 224 ]
  }
]
output [
  {
    name: "logits"
    data_type: TYPE_FP32
    dims: [ 1000 ]
  }
]

Common failure modes

Verification checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.