Unable to install python tensorrt

Hello, I have a Jetson TX2 with Jetpack 4.6.3 installed:

# R32 (release), REVISION: 7.3, GCID: 31982016, BOARD: t186ref, EABI: aarch64, DATE: Tue Nov 22 17:32:54 UTC 2022

nvidia-tensorrt (4.6.3-b17) is successfully installed on the board. However if I try to install tensorrt with pip, it fails:

/usr/bin/python3.8 -m pip install nvidia-tensorrt

Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Collecting nvidia-tensorrt
  Downloading nvidia-tensorrt-0.0.1.dev5.tar.gz (7.9 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-t6193kze/nvidia-tensorrt_0e4a9b978c63427fb703eefcc65ff71c/setup.py", line 150, in <module>
          raise RuntimeError(open("ERROR.txt", "r").read())
      RuntimeError:
      ###########################################################################################
      The package you are trying to install is only a placeholder project on PyPI.org repository.
      This package is hosted on NVIDIA Python Package Index.
      
      This package can be installed as:
      ```
      $ pip install nvidia-pyindex
      $ pip install nvidia-tensorrt
      ```
      ###########################################################################################
      
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

While /usr/bin/python3.8 -m pip install tensorrt, gives:

ERROR: Could not find a version that satisfies the requirement tensorrt (from versions: 0.0.1.dev5, 0.0.1)
ERROR: No matching distribution found for tensorrt

Both pip and setup-tools are updated

Hi,

We only provide the default python version package. For JetPack 4, it’s python3.6.

For other python versions, please build the binding from the source:

Thanks.

Hi and thank for your reply. I will try to do it

Would it work if I use a container on the TX2?

I also tried to build the bindings from source from the link that you provided but I have many questions

  • The link that you provide for downloading the archive for obtaining pyconfig.h only contains files for python 3.10 and 3.11. What if I would like to create a binding for python 3.8?
  • When you say

Copy the ./usr/include// directory into the $$EXT_PATH/pythonX.Y/include/ directory here. It should only contain a single file - pyconfig.h"

It’s not correct since is a folder that contains another folder with the name of the python version (e.g. python 3.8) and that folder contains pyconfig.h. Hence /usr/include// contains a folder and not pyconfig.h

  • When I try to build I got several errors about onnx header files
~/Downloads/TensorRT/python/build ~/Downloads/TensorRT/python
-- The CXX compiler identification is GNU 9.4.0
-- The C compiler identification is GNU 9.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xavier/Downloads/TensorRT/python/build
Scanning dependencies of target tensorrt
[  8%] Building CXX object CMakeFiles/tensorrt.dir/src/infer/pyFoundationalTypes.cpp.o
[ 16%] Building CXX object CMakeFiles/tensorrt.dir/src/infer/pyCore.cpp.o
[ 25%] Building CXX object CMakeFiles/tensorrt.dir/src/infer/pyInt8.cpp.o
[ 33%] Building CXX object CMakeFiles/tensorrt.dir/src/infer/pyGraph.cpp.o
[ 41%] Building CXX object CMakeFiles/tensorrt.dir/src/infer/pyAlgorithmSelector.cpp.o
[ 50%] Building CXX object CMakeFiles/tensorrt.dir/src/infer/pyPlugin.cpp.o
[ 58%] Building CXX object CMakeFiles/tensorrt.dir/src/parsers/pyCaffe.cpp.o
[ 66%] Building CXX object CMakeFiles/tensorrt.dir/src/parsers/pyOnnx.cpp.o
[ 75%] Building CXX object CMakeFiles/tensorrt.dir/src/parsers/pyUff.cpp.o
[ 83%] Building CXX object CMakeFiles/tensorrt.dir/src/pyTensorRT.cpp.o
[ 91%] Building CXX object CMakeFiles/tensorrt.dir/src/utils.cpp.o
In file included from /home/xavier/Downloads/TensorRT/python/src/infer/pyPlugin.cpp:18:
/home/xavier/Downloads/TensorRT/python/include/ForwardDeclarations.h:35:10: fatal error: onnx/NvOnnxParser.h: No such file or directory
   35 | #include "onnx/NvOnnxParser.h"
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
In file included from /home/xavier/Downloads/TensorRT/python/src/infer/pyCore.cpp:18:
/home/xavier/Downloads/TensorRT/python/include/ForwardDeclarations.h:35:10: fatal error: onnx/NvOnnxParser.h: No such file or directory
   35 | #include "onnx/NvOnnxParser.h"
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.

...

Hi,

Please check the below topic that contains the step-by-step instructions:

Thanks.

Thank you very much, it worked!
I suggest you to link that guide inside the README file on TensorRT/python github repository

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.