I want to use tensorRT on virtualenv

Hi!
I want to use tensorRT on virtualenv.
I already have tensorRT installed locally. How can I use tensorRT in the environment created by virtualenv? os is ubuntu 18.04.
Thanks!

2 Likes

Hi @kubo1,
Once you have the tensorRT installed in your env, you need to be sure the path of the lib.
It should be
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<TensorRT-${version}/lib>
Kindly check the below link

Thanks!

@AakankshaS
thanks.
I can’t find <TensorRT-{version}/lib> path.
In my environment, there should be a path like tensorrt-6.0.1.10/lib, but I can’t find it. There is a folder called cpp and pdf in /use/share/doc/tensorrt-6.0.1.10. Is that different?

Thanks!

1 Like

Hi @kubo1,
Yes, this is surely different.
Request you to check the installation guide.

Th elink to download TRT is

Thanks!

@AakankshaS
ok.
I already have tensorRT installed on jetson nano via jetpack. In that state, I want to use tensorRT on virtualenv. Do I still need to run the command below?

export LD_LIBRARY_PATH=LD_LIBRARY_PATH:<TensorRT-{version}/lib>

Thanks!

1 Like

Hi @kubo1,
Apologies for delayed response.
I believe so, as you will need to make your TRT visible to the environment.
Thanks!

hello,
i am facing the same problem.
have you got it working and if so how ?

Try --system-site-packages when creating your virtualenv. So a script a bit like this to create your virtualenv:

#!/bin/bash

set -e

pip3 install --user virtualenv
virtualenv --system-site-packages .venv
source .venv/bin/activate
pip install -r ./requirements/base.txt
pip install -r ./requirements/dev.txt

And it works:

...
Successfully installed ...
(.venv) [user@host] -- [~/Projects/someproject] 
 $ python3
Python 3.8.10 (default, Jun  2 2021, 10:49:15) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorrt
>>>

Of course repeatability goes out the window when you do add system site packages to your venv but there aren’t a lot of great alternatives. Unfortunately, Nvidia makes it difficult to obtain TensorRT. There’s a login wall, a mandatory survey, a dedicated apt repo, and a bunch of packages that conflict with other things. It’s frankly frustrating and makes many workflows people are used to far more difficult or impossible. It would be nice if Nvidia provided a direct download for TensorRT or included it in the primary cuda repo. Ditto for DeepStream.

2 Likes