TensorRT installation, testing and common problems

■ Installation process

1. Installation dependent environment

● Ubuntu 20.04
● CUDA 11.1
● cuDNN 8.0.4
● python 3.8.5
-You can check the cuda, cudnn, python versions through commands (the above is my installation environment)

2. Download the installation package

1. Download link: https://developer.nvidia.com/nvidia-tensorrt-download
2. Click Download Now (you need to log in to your NVIDIA account, register one if you don’t have one)
3. Select the downloaded version
4. Complete the questionnaire
5. Select Agree to the agreement
6. Choose the installation package according to your system version and CUDA version (the TensorRT version I installed is 7.2.2.3)

Three, installation instructions
  1. Unzip the tar file
tar xzvf TensorRT-7.2.2.3.Ubuntu-18.04.x86_64-gnu.cuda-11.1.cudnn8.0.tar.gz

-After decompression, there will be lib, include, data, etc...

  1. Add environment variables
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:TensorRT-7.2.2.3/lib
  1. Install python's TensorRT package
cd TensorRT-7.2.2.3/python
pip3 install tensorrt-7.2.2.3-cp38-none-linux_x86_64.whl

-Because my python version is 3.8, so I installed cp38

  1. Install python UFF package, support TensorFlow model conversion
cd TensorRT-7.2.2.3/uff
pip3 install uff-0.6.9-py2.py3-none-any.whl
  1. Install pyton graphsurgeon, support custom structure
cd TensorRT-7.2.2.3/graphsurgeon
pip3 install graphsurgeon-0.4.5-py2.py3-none-any.whl
Fourth, install PyCUDA

       PyCUDA is Python's API using NVIDIA CUDA, which maps all CUDA APIs in Python. If you want to program CUDA in Python, you must install PyCUDA.

pip3 install 'pycuda>=2019.1.1'

■ Test

       We can test whether the installation is successful by running the example below samples/python.

  1. first step:
cd samples/python/end_to_end_tensorflow_mnist
python3 model.py

– Before running, create a new folder named models in the end_to_end_tensorflow_mnist directory, and after executing model.py, a lenet5.pb will be generated in the models folder

  1. The second step:
cd samples/python/end_to_end_tensorflow_mnist
convert-to-uff ./models/lenet5.pb

-Generate a .uff file through the convert-to-uff command. If the execution is successful, lenet5.uff will be generated in the models folder

  1. third step
cd TensorRT-7.2.2.3/data/mnist
python3 download_pgms.py

– Enter mnist under the data directory and run download_pgms.py, the purpose is to generate test images.

  1. the fourth step
cd samples/python/end_to_end_tensorflow_mnist
python3 sample.py -d /home/yaoyao/TensorRT/TensorRT-7.2.2.3/data/mnist

– Pass the sample.py test, followed by -d is the path of the test image just generated.

Output: the
Insert picture description here
test is successful!

■ FAQ

Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/Roaddd/article/details/111596834