GithubHelp home page GithubHelp logo

uzkesh / tensorrt-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dkorobchenko/tensorrt-demo

0.0 0.0 0.0 1000 KB

TensorRT and TensorFlow demo/example (python, jupyter notebook)

Jupyter Notebook 93.24% Python 6.01% Shell 0.53% Dockerfile 0.21%

tensorrt-demo's Introduction

TensorRT Demo

The demo shows how to build, train and test a ConvNet using TensorFlow and then how to port it to TensorRT for fast inference.

There are two ways to perform the TensorRT optimization:

  • Build a stand-alone TensorRT engine
  • Use TensorRT+TensorFlow to build a new TF graph with optimized TRT-based subgraphs

For each step there is a py script and a Jupyter Notebook ipynb

Parameters, which could be adjusted, are marked with # ADJUST comment

TensorFlow part

Requirements: It is recommended to run everything inside tensorflow docker container (see docker details below)

TensorFlow train

Build and train a ConvNet using Tensorflow

Jupyter version: Tensorflow_train.ipynb

Python version: tf_train.py

TensorFlow graph freeze

Prepare TF graph for the inference procedure (mostly required for the further porting to TensorRT)

Jupyter version: Tensorflow_freeze.ipynb

Python version: tf_freeze.py

TensorFlow inference

Perform inference by means of TensorFlow. There are two modes: TF and TRT, which mean regular TF graph and TF graph with TRT optimizations correspondingly. The second will be available after the TensorFlow optimize step.

Jupyter version: Tensorflow_infer.ipynb

Python version: tf_infer.py

TensorFlow optimize

Use TensorRT+TensorFlow to build a new TF graph with optimized TRT-based subgraphs

Jupyter version: Tensorflow_optimize.ipynb

Python version: tf_optimize.py

TensorRT part

Requirements: It is recommended to run everything inside tensorrt docker container (see docker details below)

TensorRT optimize

Optimize frozen TF graph and prepare a stand-alone TensorRT inference engine

Jupyter version: TensorRT_optimize.ipynb

Python version: trt_optimize.py

TensorRT inference

Inference by means of TensorRT

Jupyter version: TensorRT_infer.ipynb

Python version: trt_infer.py

Docker

To avoid problems with various versions of the frameworks, it is recommended to use docker containers.

There are two containers with the following Dockerfiles:

  • tensorflow.Dockerfile contains TensorFlow 1.10 built against CUDA 10. This container is recommended for all steps from TensorFlow part
  • tensorrt.Dockerfile contains TensorRT 5.0. This container is recommended for all steps from TensorRT part

You can use either standard docker commands or docker-compose. Below is the way using standard commands.

To build docker containers use docker_build.sh

To run a docker container in bash mode (useful for python scripts) use docker_run_bash.sh TF or docker_run_bash.sh TRT

To run a docker container in jupyter mode (useful for jupyer notebooks) use docker_run_jupyter.sh TF or docker_run_jupyter.sh TRT

Jupyter notebook password is set in .env file

Jupyter notebook ports:

  • 8881 for TensorFlow container
  • 8882 for TensorRT container

Training data

The training is performed on the ImageNet dataset (ILSVRC2012, http://image-net.org). In particular, on the ImageNet subset "Tabby cat" and "Bernese mountain dog" (cats vs dogs).

You can change TRAIN_DATA_ROOT and TRAIN_LIST_FILE variables according to your localtion of the ImageNet dataset, or create a symlink /imagenet/ pointing to your location of the ImageNet.

tensorrt-demo's People

Contributors

dkorobchenko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.