|
| 1 | +# Performance Benchmarking |
| 2 | + |
| 3 | +This is a comprehensive Python benchmark suite to run perf runs using different supported backends. Following backends are supported: |
| 4 | + |
| 5 | +1. Torch |
| 6 | +2. Torch-TensorRT |
| 7 | +3. TensorRT |
| 8 | + |
| 9 | +Note: Please note that for ONNX models, user can convert the ONNX model to TensorRT serialized engine and then use this package. |
| 10 | + |
| 11 | +## Prerequisite |
| 12 | + |
| 13 | +Benchmark scripts depends on following Python packages in addition to requirements.txt packages |
| 14 | + |
| 15 | +1. Torch-TensorRT |
| 16 | +2. Torch |
| 17 | +3. TensorRT |
| 18 | + |
| 19 | +## Structure |
| 20 | + |
| 21 | +``` |
| 22 | +./ |
| 23 | +├── config |
| 24 | +│ ├── vgg16_trt.yml |
| 25 | +│ └── vgg16.yml |
| 26 | +├── models |
| 27 | +├── perf_run.py |
| 28 | +└── README.md |
| 29 | +``` |
| 30 | + |
| 31 | +Please save your configuration files at config directory. Similarly, place your model files at models path. |
| 32 | + |
| 33 | +## Usage |
| 34 | + |
| 35 | +To run the benchmark for a given configuration file: |
| 36 | + |
| 37 | +``` |
| 38 | +python perf_run.py --config=config/vgg16.yml |
| 39 | +``` |
| 40 | + |
| 41 | +## Configuration |
| 42 | + |
| 43 | +There are two sample configuration files added. |
| 44 | + |
| 45 | +* vgg16.yml demonstrates a configuration with all the supported backends (Torch, Torch-TensorRT, TensorRT) |
| 46 | +* vgg16_trt.yml demonstrates how to use an external TensorRT serialized engine file directly. |
| 47 | + |
| 48 | + |
| 49 | +### Supported fields |
| 50 | + |
| 51 | +| Name | Supported Values | Description | |
| 52 | +| --- | --- | --- | |
| 53 | +| backend | all, torch, torch_tensorrt, tensorrt | Supported backends for inference. | |
| 54 | +| input | - | Input binding names. Expected to list shapes of each input bindings | |
| 55 | +| model | - | Configure the model filename and name | |
| 56 | +| filename | - | Model file name to load from disk. | |
| 57 | +| name | - | Model name | |
| 58 | +| runtime | - | Runtime configurations | |
| 59 | +| device | 0 | Target device ID to run inference. Range depends on available GPUs | |
| 60 | +| precision | fp32, fp16 or half, int8 | Target precision to run inference. int8 cannot be used with 'all' backend | |
| 61 | +| calibration_cache | - | Calibration cache file expected for torch_tensorrt runtime in int8 precision | |
| 62 | + |
| 63 | +Note: |
| 64 | +1. Please note that torch runtime perf is not supported for int8 yet. |
| 65 | +2. Torchscript module filename should end with .jit.pt otherwise it will be treated as a TensorRT engine. |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +Additional sample use case: |
| 70 | + |
| 71 | +``` |
| 72 | +backend: |
| 73 | + - torch |
| 74 | + - torch_tensorrt |
| 75 | + - tensorrt |
| 76 | +input: |
| 77 | + input0: |
| 78 | + - 3 |
| 79 | + - 224 |
| 80 | + - 224 |
| 81 | + num_inputs: 1 |
| 82 | +model: |
| 83 | + filename: model.plan |
| 84 | + name: vgg16 |
| 85 | +runtime: |
| 86 | + device: 0 |
| 87 | + precision: |
| 88 | + - fp32 |
| 89 | + - fp16 |
| 90 | +``` |
0 commit comments