NVIDIA Jetson Xavier - Using TensorRT integrated with Tensorflow

From RidgeRun Developer Wiki



Previous: Deep Learning/TensorRT Index Next: Deep Learning‎/TensorRT/Parsing Tensorflow








Using TensorRT integrated with Tensorflow

TensorFlow is an open-source software library for numerical computation using data flow graphs. The graph nodes represent mathematical operations, while the graph edges represent the multidimensional data arrays (tensors) that flow between them. Nowadays Tensorflow is primarily used as a framework to easily develop and deploy deep learning solutions.

Starting with version 1.7 Tensorflow supports native TensorRT, which can improve latency and throughput for inference for some models. This section provides a guide for getting Tensorflow up and running on Xavier with TensorRT support.

At the end of this guide you will be able to:

  • Train deep learning models on Xavier using Tensorflow with native TensorRT support

To follow this guide you will need:

Step 1: Install Prerequisites

  • Install dependencies:
sudo apt-get install zip unzip autoconf automake libtool curl zlib1g-dev maven -y
sudo apt-get install python-numpy swig python-dev python-pip python-wheel -y

Step 2: Install Tensorflow

Download the TensorFlow wheel file for JetPack 4.0 and Install it with the following command:

sudo -H pip install tensorflow-1.10.1-cp27-cp27mu-linux_aarch64.whl

To validate your Tensorflow installatio, start a terminal and invoke python:

python

Enter the following short program using the python interactive shell:

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

If the system outputs the following, then you are ready to begin writing TensorFlow programs:

Hello, TensorFlow!

Step 3: Train a model

Clone the official tensorflow models repository and add it to the python path and install prerequisites:

git clone https://github.com/tensorflow/models.git
export PYTHONPATH="$PYTHONPATH:/path/to/models"
pip install --user -r models/official/requirements.txt

Then download and extract the CIFAR-10 data from Alex's website, specifying the location with the --data_dir flag:

python models/official/resnet/cifar10_download_and_extract.py

Then to train the model, run the following:

python models/official/resnet/cifar10_main.py

The resulting checkpoint file will be saved under /tmp/cifar10_model/. For more information on how to train a specific model please refer to the Tensorflow tutorials.



Previous: Deep Learning/TensorRT Index Next: Deep Learning‎/TensorRT/Parsing Tensorflow