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.
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.
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?
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?