TensorRT 6.0 and python

I want to run optimized inference of models built with pytorch e.g. on my desktop. The C++ example /usr/src/tensorrt/samples/sampleMNIST works. I want to try the same example in the python directory. I don’t know how to install tensorrt with pip or conda, so

import tensorrt

fails. I’m a relative newcomer to python.
Here’s the output of uname -a; nvidia-smi -L; rpm -qa | grep -e tensorrt -e python3-libnv

Linux drk 5.4.8-200.fc31.x86_64 #1 SMP Mon Jan 6 16:44:18 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
GPU 0: GeForce GTX 750 (UUID: GPU-9aff989f-201c-51cb-7db5-dcdae42a7703)

Installing the python bits also installed

python36-3.6.10-1.fc31.x86_64                    @updates




As a general solution - if you have nvidia-docker (https://github.com/NVIDIA/nvidia-docker) installed, you can easily run all kinds of frameworks and configurations (CUDA 9, 10, 10.1, 10.2) (TensorRT 5, 6, 7) (PyTorch 1.2, 1.3, 1.4), etc. using our NGC containers: https://ngc.nvidia.com/catalog/containers?orderBy=modifiedDESC&query=&quickFilter=containers&filters=

If you don’t want to use containers and only care about using the TensorRT python API specifically, the tar.gz file installation is probably the easiest method: https://docs.nvidia.com/deeplearning/sdk/tensorrt-install-guide/index.html#installing-tar

Just follow the steps to install TensorRT at the link above, then pip installing the tensorrt-*-cp3x-none-linux_x86_64.whl should allow you to do import tensorrt in your python code.

I actually figured this out a minute ago. On Fedora31, I installed the tensorrt distro rpm and later installed the python bits from the gz file. I must have messed something up because I had to install the cuda10.1 runtimes for the python bits, whereas the tensorrt distro used 10.2.
But it works!
I’ve tried a bit with docker containers, but I haven’t gotten very far. At some point I am going to be training nn’s on cloud-based gpus.