Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named 'tensorrt'

I installed TensorRT on my VM using the Debian Installation. If I run "dpkg -l | grep TensorRT" I get the expected result:

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

Yet when I try to import it in python I get:

File "<stdin>", line 1, in <module>
ImportError: No module named 'tensorrt'

What am I doing wrong?

like image 604
K41F4r Avatar asked Apr 07 '19 10:04

K41F4r


3 Answers

i had same error, solved it by installing following 2 packages:

# from TensorRT Tar Package ( TensorRT-5.0.2.6/python/ ) 
pip3 install tensorrt-5.0.2.6-py2.py3-none-any.whl  
# pycuda
pip3 install pycuda 

# libnvinfer 5.0.2-1
# libnvinfer-dev 5.0.2-1
# libnvinfer-samples 5.0.2-1
# python3-libnvinfer 5.0.2-1
# python3-libnvinfer-dev 5.0.2-1
# tensorrt 5.0.2.6
like image 57
sailfish009 Avatar answered Nov 15 '22 07:11

sailfish009


just run these commands:

pip install nvidia-pyindex
pip install nvidia-tensorrt
like image 33
Sajjad Aemmi Avatar answered Nov 15 '22 07:11

Sajjad Aemmi


two suggestions:

  1. make sure that your TensorRT is added do your path (LD_LIBRARY_PATH)
  2. if you have both python 2 and python3 installed, check for package installation in pip list and/or pip3 list
like image 38
Pidem Avatar answered Nov 15 '22 08:11

Pidem