TensorRT import - Undefined symbol

I’m trying to install TensorRT 5 from the tar file on Ubuntu 16.04, with CUDA 9.0 and cuDNN 7.3.1. Once I pip installed the wheels file, I tried

import tensorrt

in a python shell, but get

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/anaconda3/lib/python3.6/site-packages/tensorrt/__init__.py", line 1, in <module>
    from .tensorrt import *
ImportError: /usr/local/anaconda3/lib/python3.6/site-packages/tensorrt/tensorrt.so: undefined symbol: _Py_ZeroStruct

Any idea on how to solve this? I used the tar file instead of the deb file for installation because the deb file always installs in the default python /usr/bin/python instead of the conda one.

Hello,

Looks like you have a mismatch between the python interpreter you are using to run the script and the python library that is being linked by tensorrt.so.

If possible, use NVIDIA TensorRT Container (which handles all the python, cuda, tf, etc dependencies for you). https://docs.nvidia.com/deeplearning/sdk/tensorrt-container-release-notes/running.html

Thanks for your answer. I indeed tried the Docker container. Although it seems to work fine, I would like to avoid using Docker if possible. In the Docker container, the TensorRT is installed with python 3.5. Does TensorRT support python 3.6? Or are there wheels file of TensorRT compatible with python 3.6?

Hello,

Python 3.6 whl is scheduled for a future TRT release. I can’t discuss product release schedules here, but please stay tuned for announcements.

Hi NVES I met the same question.When changing conda environment from py2 to py3.

And I try docker instead but seems like docker need to give up conda environment.
Could I just link the interpreter to the lib without using docker?

Thanks

If you don’t specifically need python 3.6, you can install TensorRT from the tar file in a conda environment with python 3.5. Turns out the tar file was not previously working because my conda environment was set up in python 3.6.

Is this still the case, I just spent some time compiling TensorFlow 1.9 for Python 3.6 specifically for this use case, only to find I have to go back and repeat the compile. Did I miss a note about the Python compatibility version?

Neither Python 3.5 or Python 3.6. works for me. How you fixed this? I’m just trying to install TensorRT on AWS with Cuda 10.