TensorRT is already installed.
Search for the “tensorrt” file/directory in your system.
Unless there is a specific reason that cannot be avoided, I recommend that you use the standard 3.6.9 version of python as is.
sudo apt-get update
sudo apt-get install locate
sudo updatedb
locate tensorrt
Python virtualenv options include --system-site-packages.
This allows you to use TensorRT with virtualenv.
python3 -m virtualenv -p python3 /PATH_TO_VENV --system-site-packages
You will see that “tensorrt” is under /PATH_TO_VENV.
sudo updatedb
locate tensorrt
However, if you are familiar with how apt/pip/python virtualenv manages packages, you understand that using --system-site-packages will cause conflicts between apt packages and pip packages.
If you intentionally remove --system-site-packages to avoid conflicts between apt and pip packages, you can use tensorrt inside virtualenv by creating a symbolic link.
python3 -m virtualenv -p python3 /PATH_TO_VENV
sudo ln -s /usr/lib/python3.6/dist-packages/cv2 /PATH_TO_VENV/lib/python3.6/site-packages/cv2
sudo ln -s /usr/lib/python3.6/dist-packages/graphsurgeon /PATH_TO_VENV/lib/python3.6/site-packages/graphsurgeon
sudo ln -s /usr/lib/python3.6/dist-packages/tensorrt /PATH_TO_VENV/lib/python3.6/site-packages/tensorrt
sudo ln -s /usr/lib/python3.6/dist-packages/uff /PATH_TO_VENV/lib/python3.6/site-packages/uff