# “Hello World” For TensorRT Safety **Table Of Contents** - [Description](#description) - [How does this sample work?](#how-does-this-sample-work) * [TensorRT API layers and ops](#tensorrt-api-layers-and-ops) - [Running the sample](#running-the-sample) * [Tool command line arguments](#tool-command-line-arguments) * [When to use remoteAutoTuningConfig](#when-to-use-remoteautotuningconfig) - [Additional resources](#additional-resources) - [License](#license) - [Changelog](#changelog) - [Known issues](#known-issues) ## Description This sample, sampleSafeMNIST, consists of two parts; build and infer. The build part of this sample demonstrates how to use the builder `IBuilderConfig::setEngineCapability()` flag for safety. The inference part of this sample demonstrates how to use the safe graph. The build part builds a safe version of a TensorRT engine and saves it into a binary file, then the infer part loads the prebuilt safe engine and performs inference on an input image. ## How does this sample work? This sample uses an ONNX model that was trained on the [MNIST dataset](https://github.com/NVIDIA/DIGITS/blob/master/docs/GettingStarted.md). Specifically, this sample: - Build (sample_mnist_safe_build): - Performs the basic setup and initialization of TensorRT - [Imports a trained ONNX model using ONNX parser](https://docs.nvidia.com/deeplearning/tensorrt/latest/inference-library/c-api-docs.html#importing-a-model-using-the-onnx-parser) - Preprocesses the input and stores the result in a managed buffer - [Builds a safe engine](https://docs.nvidia.com/deeplearning/tensorrt/latest/inference-library/c-api-docs.html#building-an-engine) - Infer (sample_mnist_safe_infer): - Create a safe graph for setting up tensors and executing inference on a built network. To verify whether the engine is operating correctly, this sample picks a 28x28 image of a digit at random and runs inference on it using the engine it created. The output of the network is a probability distribution on the digit, showing which digit is likely that in the image. ### TensorRT API layers and ops In this sample, the following layers are used. For more information about these layers, see the [TensorRT API: Layers](https://docs.nvidia.com/deeplearning/tensorrt/api/python_api/infer/Graph/Layers.html) documentation. [Activation layer](https://docs.nvidia.com/deeplearning/tensorrt/operators/docs/Activation.html) The Activation layer implements element-wise activation functions. Specifically, this sample uses the Activation layer with the type `kRELU`. [Convolution layer](https://docs.nvidia.com/deeplearning/tensorrt/operators/docs/Convolution.html) The Convolution layer computes a 2D (channel, height, and width) convolution, with or without bias. ## Running the sample 1. Download the [MNIST dataset](https://github.com/NVIDIA/DIGITS/blob/master/docs/GettingStarted.md) to read images from the ubyte file. The images need to be saved into `.pgm` format and renamed as `