How to install TensorRT?

I have Jetpack 5.1.1 installed, and I am using a Nvidia Jetson AGX Orin 32GB H01.
I want to use TensorRT to optimize and speed up YoloP, so I used the command sudo apt-get install tensorrt nvidia-tensorrt-dev python3-libnvinfer-devto install TensorRT.
I cannot import tensorrt while i am in my virtual environment, so I used the command pip install nvidia-tensorrt, but it gave an error message.

pip install pycuda and pip install nvidia-tensorrt fail, but I am able to import tensorrt while i am outside the virtual environment and cd Home

(venv) orin@NvidiaJetson:~/venv/AY2024/TensorRT$ pip install nvidia-tensorrt
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-1d8rmo_x/nvidia-tensorrt_5c16844670ff4dbba2e9f8fa3c01f586/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.

Hi,

Please install TensorRT python with the below command:

Thanks.

Hi,

I have run the command and it says libnvinfer-dev and libnvinfer is already the newest version (8.4.1-1+cuda11.4).

The problem is I cannot import tensorrt while i am in a virtual environment. How do I change that?

Hi,

Could you try to create the virtul environment with --system-site-packages?
Thanks.

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