Table Of Contents
- Description
- How does this sample work?
- Prerequisites
- Running the sample
- Additional resources
- License
- Changelog
- Known issues
This sample, introductory_parser_samples, is a Python sample which uses TensorRT and its included ONNX parser, to perform inference with ResNet-50 models saved in ONNX format.
This sample demonstrates how to build an engine from an ONNX model file using the open-source ONNX parser and then run inference. The ONNX parser can be used with any framework that supports the ONNX format (typically .onnx
files).
- Install the dependencies for Python.
pip3 install -r requirements.txt
On Jetson Nano, you will need nvcc in the PATH
for installing pycuda:
export PATH=${PATH}:/usr/local/cuda/bin/
-
Run the sample to create a TensorRT inference engine and run inference:
python3 onnx_resnet50.py
Note: If the TensorRT sample data is not installed in the default location, for example
/usr/src/tensorrt/data/
, thedata
directory must be specified. For example:python3 onnx_resnet50.py -d /path/to/my/data/
-
Verify that the sample ran successfully. If the sample runs successfully you should see output similar to the following:
Correctly recognized data/samples/resnet50/reflex_camera.jpeg as reflex camera
To see the full list of available options and their descriptions, use the -h
or --help
command line option. For example:
usage: onnx_resnet50.py [-h] [-d DATADIR]
Runs a ResNet50 network with a TensorRT inference engine.
optional arguments:
-h, --help show this help message and exit
-d DATADIR, --datadir DATADIR
Location of the TensorRT sample data directory.
(default: /usr/src/tensorrt/data)
The following resources provide a deeper understanding about importing a model into TensorRT using Python:
ResNet-50
Parsers
Documentation
- Introduction To NVIDIA’s TensorRT Samples
- Working With TensorRT Using The Python API
- Importing A Model Using A Parser In Python
- NVIDIA’s TensorRT Documentation Library
For terms and conditions for use, reproduction, and distribution, see the TensorRT Software License Agreement documentation.
Auguest 2022 Removed options for Caffe and UFF parsers.
February 2019
This README.md
file was recreated, updated and reviewed.
There are no known issues in this sample