Python binding not found for TensorRT.

Linux distro and version : ubuntu 18.04
GPU type : NVIDIA GTX 1060
nvidia driver version : 415.27
CUDA version : 10.1
CUDNN version : 9.1
Python version [if using python] : 3.6.2
Tensorflow version : 1.13
TensorRT version : 5.0
If Jetson, OS, hw versions : n/a

I’ve followed the instruction as to install tensorRT, everything went good, however, I couldn’t import tensorrt module in python.

After, installation i checked if python binding shows up or no.

(myenv) jugs@jugs:~$ dpkg -l | grep TensorRT
ii  graphsurgeon-tf                                             5.0.2-1+cuda10.0                             amd64        GraphSurgeon for TensorRT package
ii  libnvinfer-dev                                              5.0.2-1+cuda10.0                             amd64        TensorRT development libraries and headers
ii  libnvinfer-samples                                          5.0.2-1+cuda10.0                             all          TensorRT samples and documentation
ii  libnvinfer5                                                 5.0.2-1+cuda10.0                             amd64        TensorRT runtime libraries
ii  python-libnvinfer                                           5.0.2-1+cuda10.0                             amd64        Python bindings for TensorRT
ii  python-libnvinfer-dev                                       5.0.2-1+cuda10.0                             amd64        Python development package for TensorRT
ii  python3-libnvinfer                                          5.0.2-1+cuda10.0                             amd64        Python 3 bindings for TensorRT
ii  python3-libnvinfer-dev                                      5.0.2-1+cuda10.0                             amd64        Python 3 development package for TensorRT
ii  tensorrt                                                    5.0.2.6-1+cuda10.0                           amd64        Meta package of TensorRT
ii  uff-converter-tf                                            5.0.2-1+cuda10.0                             amd64        UFF converter for TensorRT package
(myenv) jugs@jugs:~$

Regardless, everything is available, but I still couldn’t import the python module.
I have a tensorflow version 1.13, and python 3.x in anaconda environment,

Python 3.6.2 |Anaconda, Inc.| (default, Oct  5 2017, 07:59:26) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> print(tf.__version__)
1.13.1
>>> import tensorrt as trt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorrt'
>>>

And, my NVIDIA driver and cuda driver version is as shown below,

(myenv) jugs@jugs:~$ nvidia-smi
Fri Jun 14 12:24:44 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 415.27       Driver Version: 415.27       CUDA Version: 10.0     |
|-------------------------------+----------------------+----------------------+

same issue. do you have this resolved?

Hi,

This issue is usually related to the difference between a system Python3 install and an Anaconda Python3 install. The debian TensorRT package installation seems to use the system Python3 version.

First, I believe the TensorRT Python3 package is usually for Python3.5 by default and your Anaconda version is Python3.6.2. So you could try to downgrade your Anaconda version to 3.5 to see if it can pick up TensorRT as mentioned in this post: https://devtalk.nvidia.com/default/topic/1030265/tensorrt/python-quot-import-tesnorrt-quot-error-modulenotfounderror-no-module-named-tensorrt-/post/5261495/#5261495

Or you could try uninstalling Anaconda and just using the system Python3 version instead as mentioned here: https://devtalk.nvidia.com/default/topic/1030265/tensorrt/python-quot-import-tesnorrt-quot-error-modulenotfounderror-no-module-named-tensorrt-/post/5241538/#5241538

Thanks,
NVIDIA Enterprise Support

Is Python3.5 a hard requirement for installing the python binding of TensorRT-6.0.1.5? The TensorRT install guide does not indicate at any point that a particular Python version is required.

I have Ubuntu 18.04 with Python3.6.8 only (not any Python3.5.x is installed on my machine). I tried to install TensorRT-6.0.1.5 from
(1) Debian package
(2) tar file

in a virtual environment (created with venv).

I was able to complete each of the installation procedures without any error messages. In both cases TesnsorRT can not be imported in Python inside my virtual environment:

import tensorrt as trt
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘tensorrt’

However, if I deactivate the virtual environment and start the system Python3, I can import TensorRT, i.e.

import tensorrt as trt

goes through without error message. (Of course, all other packages they I need are installed in the virtual environment only and so I do not have a working combination.)

Do I miss anything special I need to do to install TensorRT in a virtual environment? Or the Python version (3.5 vs 3.6) might be a problem?

Bump this. I can also confirm my python3-libnvinfer package is installed correctly, but not visible inside a virtual environment.

The only fix I’ve found is here, where they say I have to add my dist-packages to my virtual environment. Which kinda defeats the point of a virtual environment