GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - yester31/TensorRT_Examples: TensorRT in Practice: Model Conversion, Extension, and Advanced Inference Optimization

BranchesTags
Open more actions menu

Latest commit

 

History

132 Commits
132 Commits

Folders and files

NameName
Last commit message
Last commit date
general_models
general_models
 
 
optimization_techniques
optimization_techniques
 
 
practical_tutorial
practical_tutorial
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
common.py
common.py
 
 
common_runtime.py
common_runtime.py
 
 
compare.py
compare.py
 
 
utils.py
utils.py
 
 

Repository files navigation

Examples of TensorRT models using ONNX

All useful sample codes of TensorRT models using ONNX

0. Development Environment

  • RTX3060 (notebook)
  • WSL
  • Ubuntu 22.04.5 LTS
  • cuda 12.9

conda deactivate conda env remove -n trte -y

Set up a virtual environment.

conda create -n trte python=3.11 --yes 
conda activate trte

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu129
pip install cuda-python==12.9.2
pip install tensorrt-cu12
pip install -U "nvidia-modelopt[all]"

# Check installation 
python -c "import modelopt; print(modelopt.__version__)"
python -c "import modelopt.torch.quantization.extensions as ext; ext.precompile()"

pip install opencv-python
pip install timm
pip install matplotlib
pip install onnxsim

1. TensorRT Model Conversion and Extension: A Practical Tutorial

  1. Generation TensorRT Model by using ONNX
    1.1 TensorRT CPP API
    1.2 TensorRT Python API
    1.3 Polygraphy

  2. Dynamic shapes for TensorRT
    2.1 Dynamic batch
    2.2 Dynamic input size

  3. Custom Plugin
    3.1 Adding a pre-processing layer by cuda

  4. Modifying an ONNX graph by ONNX GraphSurgeon
    4.1 Extracting a feature map of the last Conv for Grad-Cam
    4.2 Generating a TensorRT model with a custom plugin and ONNX

2. Advanced Optimization Techniques for TensorRT Inference

  1. Base model train & convert
    1.1 Train Base Model (resnet18)
    1.2 Base TensorRT (fp16)
  2. Quantization
    2.1 Explict Quantization (PTQ)
    2.2 Explict Quantization (QAT)
    2.3 Explict Quantization (ONNX PTQ)
    2.4 Implicit Quantization (TensorRT PTQ)
  3. Sparsity
    3.1 Sparsity (2:4 sparsity)
  4. Pruning
    4.1 Pruning
  5. NAS
    5.1 NAS(work in progress...)
  6. Multiple Optimizations
    6.1 (Pruning + Sparsity)
    6.2 (Pruning + Sparsity + Quantization(QAT))
Framework PyTorch TensorRT TensorRT TensorRT TensorRT TensorRT TensorRT TensorRT
Opti Technique - - trt ptq (Implicit) onnx ptq (Explict) tmo ptq (Explict) tmo qat (Explict) tmo sparsity tmo pruning (flops 80%)
Precision fp16 fp16 int8 int8 int8 int8 fp16 fp16
Top-1 Acc [%] 84.58 84.54 84.34 84.5 84.2 84.42 83.28 82.76
Top-5 Acc [%] 97.2 97.2 97.1 97 97.06 97.1 96.72 96.42
FPS [Frame/sec] 406.27 1463.45 1915.04 1897.46 1542.34 1572.81 1483.85 1573.2
Avg Latency [ms] 2.46 0.68 0.52 0.53 0.65 0.64 0.67 0.64
GPU Mem [MB] 286 138 124 124 124 138 138 130

3. Conversion of General Deep Learning Models to TensorRT

  1. Super Resolution
    1.1 Real-ESRGAN

  2. Object Detection
    2.1 Yolo11
    2.2 Yolo12
    2.3 D-FINE
    2.4 YOLOX (with CPP demo)
    2.5 Dome-DETR
    2.6 RF-DETR
    2.7 RT-DETR
    2.8 DEIM

  3. Instance Segmentation

  4. Semantic Segmentation
    4.1 U-2-Net(Sky Segmentation)
    4.2 BEN2(Remove Background)
    4.3 MODNet(Portrait Matting)
    4.4 ORMBG(Remove Background for images with humans)

  5. Panoptic Segmentation
    5.1 EoMT

  6. Depth Estimation
    6.1 Depth-Pro(Sharp Monocular Metric Depth)

  7. Gaze Target Estimation
    7.1 Gaze-LLE

  8. SAM Series
    8.1 SAM2
    8.2 EfficientViT-SAM

  9. Optical Flow
    9.1 RAFT
    9.2 MeFlow
    9.3 MEMFOF
    9.4 NeuFlow

4. reference

  • TensorRT
  • TensorRT-Model-Optimizer

About

TensorRT in Practice: Model Conversion, Extension, and Advanced Inference Optimization

Topics

d-finedepth-proefficientvitsameomtinference-optimizationonnxpost-training-quantizationpruningquantizationquantization-aware-trainingreal-esrgansam2sparsitytensorrtyolov12

Resources

Readme
MIT license
Activity

Stars

10 stars

Watchers

2 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.