# Keras-\>ONXX-\>TensorRT

**URL:** <https://forums.developer.nvidia.com/t/keras-onxx-tensorrt/116133>\
**Category:** TensorRT\
**Created:** [March 19, 2020, 7:21pm UTC](https://forums.developer.nvidia.com/t/keras-onxx-tensorrt/116133 "2020-03-19T19:21:51Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![NVES\_R](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nves_r/32/14043_2.png) [@NVES\_R](https://forums.developer.nvidia.com/u/NVES_R)\
**Post date:** [March 26, 2020, 4:56am UTC](https://forums.developer.nvidia.com/t/keras-onxx-tensorrt/116133/6 "2020-03-26T04:56:34Z")

</div>

Ah, sorry - I used `trtexec --explicitBatch --onnx=model.onnx`, which I believe creates a dummy profile for batch size 1, if not specified, by default for the sake of parsing.

You can also reference this thread for how to create profiles using `trtexec` if interested: [TensorRT 7 ONNX models with variable batch size - #6 by NVES\_R](https://forums.developer.nvidia.com/t/tensorrt-7-onnx-models-with-variable-batch-size/115302/6)

* * *

For doing this with the Python API, you could reference this script: [https://github.com/rmccorm4/tensorrt-utils/blob/master/classification/imagenet/onnx\_to\_tensorrt.py](https://github.com/rmccorm4/tensorrt-utils/blob/master/classification/imagenet/onnx_to_tensorrt.py), which will create some default optimization profiles for various batch sizes.

It should work with something like:

```auto
python3 onnx_to_tensorrt.py --explicit-batch --onnx=model.onnx 

```

You can tweak/use parts of the code for your needs, you definitely don’t have to use it as is.

---

_[View the full topic](https://forums.developer.nvidia.com/t/keras-onxx-tensorrt/116133)._
