Table Of Contents
This sample, sampleAlgorithmSelector, shows an example of how to use the algorithm selection API based on sampleMNIST. sampleMNIST documentation
This sample demonstrates the usage of IAlgorithmSelector
to deterministically build TRT engines. It also shows the usage of IAlgorithmSelector::selectAlgorithms
to define heuristics for selection of algorithms.
This sample uses a Caffe model that was trained on the MNIST dataset.
Specifically, this sample performs the following steps:
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 to be that in the image.
IAlgorithmSelector::reportAlgorithms
to write TensorRT's default algorithm choices to a file "AlgorithmChoices.txt".IAlgorithmSelector::selectAlgorithms
to replicate algorithm choices from the file "AlgorithmChoices.txt" and verifies the choices using IAlgorithmSelector::reportAlgorithms
.IAlgorithmSelector::selectAlgorithms
to select algorithms with minimum workspace requirements.make
in the <TensorRT root directory>/samples/sampleAlgorithmSelector
directory. The binary named sample_algorithm_selector
will be created in the <TensorRT root directory>/bin
directory. ``` cd <TensorRT root directory>/samples/sampleAlgorithmSelector make `` Where
<TensorRT root directory>` is where you installed TensorRT.Run the sample to perform inference on the digit: ``` ./sample_algorithm_selector [-h] [–datadir=/path/to/data/dir/] [–useDLA=N] [–fp16 or –int8] ``` This sample reads three Caffe files to build the network:
mnist.prototxt
The prototxt file that contains the network design.mnist.caffemodel
The model file which contains the trained weights for the network.mnist_mean.binaryproto
The binaryproto file which contains the means.This sample can be run in FP16 and INT8 modes as well.
Note: By default, the sample expects these files to be in either the data/samples/mnist/
or data/mnist/
directories. The list of default directories can be changed by adding one or more paths with --datadir=/new/path/
as a command line argument.
Verify that the sample ran successfully. If the sample runs successfully you should see output similar to the following; ASCII rendering of the input image with digit 3: ``` &&&& RUNNING TensorRT.sample_algorithm_selector # ./sample_algorithm_selector [I] Building and running a GPU inference engine for MNIST [I] Input: @@@@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@#-:.-=@@@@@@@ @@%= . @@@@@@@ @@% .:+%%% *@@@@@@@ @@+=#@@# @@@@@@@ @@@@@% @@@@@@@ @@@@@@: *@@@@@@@ @@@@@- .@@@@@@@@ @@@@@: #@@@@@@@@ @@@@: +%#@@@@@@ @@@% :+*@@@@ @@@@#*+–.:: +@@@ @@@@@@@@#=:. +@@@ @@@@@@@@@@ .@@@ @@@@@@@@@@#. #@@ @@@@@@@@@@# @@@ @@@@%@@@@@- +@@@ @@@@#-@@@@*. =@@@ @@@@ .+%%%%+=. =@@@@ @@@@ =@@@@ @@@@*=: :–*@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@@@@@@
[I] Output: 0: 1: 2: 3: ********** 4: 5: 6: 7: 8: 9:
&&&& PASSED TensorRT.sample_algorithm_selector # ./sample_algorithm_selector ```
This output shows that the sample ran successfully; PASSED
.
To see the full list of available options and their descriptions, use the -h
or --help
command line option. For example:
The following resources provide a deeper understanding about sampleAlgorithmSelector:
MNIST
Documentation
For terms and conditions for use, reproduction, and distribution, see the TensorRT Software License Agreement documentation.
November 2019 This README.md
file was recreated, updated and reviewed.
There are no known issues in this sample.