python "import tesnorrt" error: ModuleNotFoundError: No module named 'tensorrt'

Hi,

I’m getting ‘ModuleNotFoundError’ error when I import tesnorrt. I’ve ubuntu 16.04 and my GPU is TitanX (Pascal). Import uff throws the same error. I installed nv-tensorrt-repo-ubuntu1604-ga-cuda9.0-trt3.0.4-20180208_1-1_amd64.deb and folllowed instructions provided by NVIDIA (Debian Installation): [url]Installation Guide :: NVIDIA Deep Learning TensorRT Documentation and I verify that it’s been installed.

Other information that might help:

  • NVidia driver version: 384.111
  • Anaconda Python 3.6.4
  • Cuda 9.0
  • cuDNN 7.0.5
  • gcc 4.8
  • swig installed
  • “import pycuda” works

and my environment variables are:
[i]# added by Anaconda3 installer
export PATH=“/home/administrator/anaconda3/bin:$PATH”

added by Nejla

export CUDA_ROOT=/usr/local/cuda-9.0
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda-9.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64[/i]

What am I missing or have done wrong?!
Thanks

Thank you. I finally got it working. I’d three python installations: python 2.7 coming with ubuntu, python 3.5 coming with ubuntu and anaconda python 3.5 that I’d installed myself. Got rid of Anaconda 3.5 as I couldn’t control where tensorrt is installed and made 3.5 the default one and reinstalled tensorrt, python packages as well as pycuda. Now, it’s working.

Hello all,

I have the same issue. I am trying to install tensorrt at a cloud machine (paperspace) with ubuntu 16.04 and Nvidia Quadro P4000. I have followed the instructions in [url]Installation Guide :: NVIDIA Deep Learning TensorRT Documentation and I have gone through the Debian installation (nv-tensorrt-repo-ubuntu1604-cuda9.0-rc-trt4.0.0.3-20180329_1-1_amd64.deb). To verify the installation, I get these:

ii libnvinfer-dev 4.1.0-1+cuda9.0 amd64 TensorRT development libraries and headers
ii libnvinfer-samples 4.1.0-1+cuda9.0 amd64 TensorRT samples and documentation
ii libnvinfer4 4.1.0-1+cuda9.0 amd64 TensorRT runtime libraries
ii python-libnvinfer 4.1.0-1+cuda9.0 amd64 Python bindings for TensorRT
ii python-libnvinfer-dev 4.1.0-1+cuda9.0 amd64 Python development package for TensorRT
ii python-libnvinfer-doc 4.1.0-1+cuda9.0 amd64 Documention and samples of python bindings for TensorRT
ii python3-libnvinfer 4.1.0-1+cuda9.0 amd64 Python 3 bindings for TensorRT
ii python3-libnvinfer-dev 4.1.0-1+cuda9.0 amd64 Python 3 development package for TensorRT
ii python3-libnvinfer-doc 4.1.0-1+cuda9.0 amd64 Documention and samples of python bindings for TensorRT
ii tensorrt 4.0.0.3-1+cuda9.0 amd64 Meta package of TensorRT
ii uff-converter-tf 4.1.0-1+cuda9.0 amd64 UFF converter for TensorRT package

However, the ‘import tensorrt as trt’ returns:
ModuleNotFoundError: No module named ‘tensorrt’

Other info regarding my specs:

  • NVidia driver version: 387.34
  • Anaconda Python 3.6.5 ***
  • Cuda 9.1.85
  • cuDNN 7.0.5
  • pycuda 2017.1.1
  • gcc 5.4
  • swig 3.0.8
  • “import pycuda” works

Showing that all seems to be installed properly, I am getting confused about the python
*** whereis python >>>
python: /usr/bin/python /usr/bin/python3.5 /usr/bin/python2.7 /usr/bin/python3.5m /usr/lib/python3.5 /usr/lib/python2.7 /etc/python /etc/python3.5 /etc/python2.7 /usr/local/lib/python3.5 /usr/local/lib/python2.7 /usr/share/python /home/paperspace/anaconda3/envs/fastai/bin/python3.6 /home/paperspace/anaconda3/envs/fastai/bin/python /home/paperspace/anaconda3/envs/fastai/bin/python3.6-config /home/paperspace/anaconda3/envs/fastai/bin/python3.6m /home/paperspace/anaconda3/envs/fastai/bin/python3.6m-config /home/paperspace/anaconda3/bin/python3.6 /home/paperspace/anaconda3/bin/python /home/paperspace/anaconda3/bin/python3.6-config /home/paperspace/anaconda3/bin/python3.6m /home/paperspace/anaconda3/bin/python3.6m-config /usr/share/man/man1/python.1.gz /usr/src/tensorrt/python

Any help on this please?

Did you import tensorflow and uff before?
Like this:
import tensorflow as tf
import uff
import tensorrt as trt

And are you sure tensorrt is installed in your conda environment python and not on the system python?

I fixed the problem by making sure that the tensorrt is installed in my conda environment. That was the confusion. @eknic Thanks for the reply.

@athanossios: how exactly did you ensure that tensorrt was installed in your conda environment? Did you build from the tar?

When installing from the debian package, it seems like it would always use the system python3 and not the conda environment.

2 Likes

Initially, I tried with the Debian installation but later I switched to the tar and it worked.
TensorRT does not support python 3.6, so make sure to downgrade it:

conda install python=3.5.0
which python

, will show you the default python kernel.
If you use Jupyter notebook, you can change kernel like: Kernel >> Change Kernel >> Environment ().

Cold you tell me how to making sure that tensort is installed in conda environment?