Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to install tensorrt for pytorch in conda environment #429

Open
govindamagrawal opened this issue Oct 19, 2020 · 4 comments
Open

How to install tensorrt for pytorch in conda environment #429

govindamagrawal opened this issue Oct 19, 2020 · 4 comments

Comments

@govindamagrawal
Copy link

Hi,
Can someone please guide how to install tensorrt properly in conda environment. I have install tensorrt though downloading .whl file from nvidia repo and it got installed by running this command in the conda activated env:

pip install /home/govindam/TensorRT-7.0.0.11/python/tensorrt-7.0.0.11-cp37-none-linux_x86_64.whl

But it also requires to install other dependencies like python3-libnvinfer-dev etc which I guess can be installed only via sudo, but will not work in the conda environment. I am getting error like this when trying to import torch2trt:

>>> from torch2trt import torch2trt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/govindam/anaconda3/envs/tf_c9/lib/python3.7/site-packages/torch2trt-0.1.0-py3.7-linux-x86_64.egg/torch2trt/__init__.py", line 1, in <module>
    from .torch2trt import *
  File "/home/govindam/anaconda3/envs/tf_c9/lib/python3.7/site-packages/torch2trt-0.1.0-py3.7-linux-x86_64.egg/torch2trt/torch2trt.py", line 2, in <module>
    import tensorrt as trt
  File "/home/govindam/anaconda3/envs/tf_c9/lib/python3.7/site-packages/tensorrt/__init__.py", line 1, in <module>
    from .tensorrt import *
ImportError: libnvrtc.so.10.0: cannot open shared object file: No such file or directory

Can someone please help to install the package ? Thanks in advance.

@ravijo
Copy link

ravijo commented Mar 9, 2021

Please follow the instructions given on the official website . Assuming you have installed Cuda and cuDNN properly, you can install TensorRT using pip using the following commands:

pip install nvidia-pyindex
pip install nvidia-tensorrt

Please make sure to have updated versions of pip and setuptools by executing pip3 install --upgrade setuptools pip. After installing TensorRT, you can verify the installation as shown below:

(my_env) ravi@home:~$ ipython
Python 3.7.10 (default, Feb 26 2021, 18:47:35) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.21.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import tensorrt

In [2]: tensorrt.__version__
Out[2]: '7.2.3.4'

In [3]: assert tensorrt.Builder(tensorrt.Logger())

In [4]: tensorrt.__file__
Out[4]: '/home/ravi/anaconda/envs/my_env/lib/python3.7/site-packages/tensorrt/__init__.py'

In [5]: import torch

In [6]: torch.__version__
Out[6]: '1.7.0'

In [7]: torch.version.cuda
Out[7]: '11.0'

In [8]: ls /home/ravi/anaconda/envs/my_env/lib/python3.7/site-packages/tensorrt/
__init__.py  libmyelin.so.1  libnvinfer_plugin.so.7  libnvinfer.so.7  libnvonnxparser.so.7  libnvparsers.so.7  __pycache__/  tensorrt.so*

You may see the following installation locations too:

  • tensorrt.so is installed at /home/ravi/anaconda/envs/my_env/lib/python3.7/site-packages/tensorrt/
  • libnvrtc.so is installed at /home/ravi/anaconda/envs/my_env/lib/libnvrtc.so

@MalusJ
Copy link

MalusJ commented Mar 16, 2021

ImportError: libnvrtc.so.10.0: cannot open shared object file: No such file or directory

I think it's because your cuda version doesnt match what TensorRT needed. Try update your cuda to 10.0 and run it.

@govindamagrawal
Copy link
Author

Thanks for the reply,

@gioipv
Copy link

gioipv commented Aug 4, 2021

I installed tensorrt with tar file in conda environment.
in the steps to install tensorrt with tar file, using pip install instead of sudo pip install. Because if u use sudo, the tensorrt use python system instead of python in conda. and u have to update python path to use tensorrt, but it is not the python version in your env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants