But when i run the Python API i get following Error:
File "/home/gustav/workspace/TensorRT/tf_to_trt.py", line 10, in <module>
import tensorrt as trt
File "/usr/lib/python2.7/dist-packages/tensorrt/__init__.py", line 53, in <module>
from tensorrt import __versions__
ImportError: cannot import name __versions__
Any Solutions to that? Inside the versions file stands following:
'''
Version information for the TensorRT Python API
'''
package_version = '3.0.1'
infer_lib_version = 301
so_version = '4.0.1'
cudnn_version = '7.0'
Hey dusty_nv, yes i found a very simple solution as it is written in your TensorRT Release Notes (maybe this usefull file should be highlighted a little bit more :) )
You have to import uff and tensorflow before you import tensorrrt (even if you dont use tensorflow in the code)
The reason is said to be:
“When using the TensorRT APIs from Python, import the tensorflow and uff
modules before importing the tensorrt module. This is required to avoid a
potential namespace conflict with the protobuf library as well as the cuDNN
version. In a future update, the modules will be fixed to allow the loading of these
Python modules to be in an arbitrary order.”
I’m getting ‘ModuleNotFoundError’ error. I’ve ubuntu 16.04 and my GPU is TitanX (Pascal). I tried what pratosha suggested by first importing tesnorflow and uff. But, I can’t even import uff. 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.
Thank you for your reply. I ran those commands and when I run dpkg -l | grep TensorRT I see the output that is provided at section 2 of the installation guide. But, it’s not working! My NVidia driver version is 384.111. Do you think that’s causing problem?! Do I need to set a specific environment variable? My environment variables are:
[i]# added by Anaconda3 installer
export PATH=“/home/administrator/anaconda3/bin:$PATH”
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.
Unfortunately, you can’t use anaconda with TensorRT but you can still have anaconda on your system. To make tensorRT work I think it’s better to figure out what version of Python the tensorRT has been installed under and then make that version your default version and install other libraries under that version (tensorflow, …). You don’t have control where to install tensorRT but you’ve control on everything else.
Hi there AastaLLL,
I’m having sort of the same issue, but with CUDA 9.2 and TensorRT 4.
I have numpy version 1.11 on Ubuntu 16.04 x86
When trying to import tensorrt with:
import tensorrt as trt
I get:
ImportError: numpy.core.multiarray failed to import
Then I import numpy.core.multiarray and try again and this time I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/tensorrt/__init__.py", line 53, in <module>
from tensorrt import __versions__
ImportError: cannot import name __versions__
As I’ve seen in this thread I have to import tensorflow and uff first. I had tensorflow for CUDA 9.0 so I gave it a try but can’t import uff or tensorflow due to:
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory