You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
❓ [Question] How to install torch_tensorrt python API in ubuntu 20.04? #1133
I want to install torch_tensorrt python API in ubuntu 20.04. could you please provide step by a step installation procedure? I tried pip3 install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releases
when I try to import the module import torch_tensorrt
I'm getting the below error,
Environment
Build information about Torch-TensorRT can be found by turning on debug messages
PyTorch Version (e.g., 1.0): 1.11.0
CPU Architecture:
OS (e.g., Linux): LINUX
How you installed PyTorch (conda, pip, libtorch, source): conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
Build command you used (if compiling from source):
Are you using local sources or building from archives:no
(2) and (3)
Get the debs from the links in PyTorch docs and install.
(in a virtual env)
(4) I use pip, so I pip install pytorch
(5) pip install tensorrt pip3 install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releases
then using pip command pip3 install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releases I installed torch_tensorrt.
however, the weird part is, if import torch_tensorrt as a first module in script it throws the same error
It doesn't look like those instructions are complete as you're still missing libnvinfer. So I would follow what's in the PyTorch docs.
I've only been able to get a successful system up and running using what I posted . . . Other instructions may work, but I find they're sometimes missing steps or assume you've done something without being explicit about it.
If you're confident you've got cuda, cudnn, and tensorrt running, the other thing to check is if you've got proprietary nvidia drivers installed and they can see your gpu.
(1) Can you run (in a terminal) nvidia-smi and post what you get.
(2) In python, check if it can see your GPU:
import torch
torch.cuda.is_available() # should return True
torch.cuda.device_count() # how many devices you have
torch.cuda.current_device() # which one you're using now
torch.cuda.get_device_name(0) # what you got above to see what it thinks it is
@dignakov , after some continuous debugging and with your support. Now, I'm able install torch_tensorrt. please find the screenshot
however, I still have a question, when I looked into PyTorch official installation page, it has many steps like installing C++ and bazel and python3 setup.py [install/bdist_wheel] and python3 setup.py install --use-cxx11-abi
So, here my question is do I still need to install all those or am I good to go with the above installation?
Unless you'd like to build everything from source, you should be okay just with the "Precompiled Binaries" section. That's everything you need for the "Python API", if you can import torch_tensorrt and use it, you shouldn't need to do anything else.
The section you're talking about is titled "Compiling From Source", and that's for building everything from scratch . . .
Can you try installing the latest package, as long as you have cuda installed all other dependencies will get installed for you via pip. If the issue persists reopen the issue.
Activity
dignakov commentedon Jun 19, 2022
Looks like it can't find one of it's dependencies.
You could try following the PyTorch docs: https://pytorch.org/TensorRT/tutorials/installation.html
You'll need to install the different parts manually to get the wheel to eventually work, it does not bundle anything.
(1) install CUDA: https://developer.nvidia.com/cuda-zone
(2) install CUDNN: https://developer.nvidia.com/cudnn
(3) install TensorRT: https://developer.nvidia.com/tensorrt
(in a venv)
(4) install PyTorch: https://pytorch.org/
(5) pip install tensorrt
pip3 install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releasesIf you run into missing instructions you can post here and I'll try to go back through my bash history.
This is what I do:
(1)
(2) and (3)
Get the debs from the links in PyTorch docs and install.
(in a virtual env)
(4) I use pip, so I pip install pytorch
(5) pip install tensorrt
pip3 install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releasesIamExperimenting commentedon Jun 19, 2022
@dignakov , thanks for your reply,
Steps i followed the below steps,
pip3 install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releasesI installed torch_tensorrt.however, the weird part is, if
import torch_tensorrtas a first module in script it throws the same errorError
same as my above screenshot.
if i do like the below steps
it gives warning.
dignakov commentedon Jun 19, 2022
It doesn't look like those instructions are complete as you're still missing
libnvinfer. So I would follow what's in the PyTorch docs.I've only been able to get a successful system up and running using what I posted . . . Other instructions may work, but I find they're sometimes missing steps or assume you've done something without being explicit about it.
If you're confident you've got cuda, cudnn, and tensorrt running, the other thing to check is if you've got proprietary nvidia drivers installed and they can see your gpu.
(1) Can you run (in a terminal)
nvidia-smiand post what you get.(2) In python, check if it can see your GPU:
IamExperimenting commentedon Jun 19, 2022
@dignakov you're right it didn't work now after I restarted the kernel.
could you please help me to install it? To be honest, I'm familiar with installing using Linux commands. But I'm trying my best.
dignakov commentedon Jun 19, 2022
@IamExperimenting can you try following what I had in my comment above (#1133 (comment))?
(1) is exactly how I usually do it.
for (2) and (3) you can just download the debs and run
sudo apt install ./whatever.debI don't use conda, so if you want to follow the instructions below, you need to deactivate any conda environments.
(4) and (5) - I make a virtual environment
python3 -m venv envsource it
source env/bin/activate(you'll need to do this every time you want to use pytorch)install pytorch
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113install torch-tensorrt
pip3 install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releasesIamExperimenting commentedon Jun 19, 2022
@dignakov , after some continuous debugging and with your support. Now, I'm able install torch_tensorrt. please find the screenshot

however, I still have a question, when I looked into PyTorch official installation page, it has many steps like installing C++ and bazel and
python3 setup.py [install/bdist_wheel]andpython3 setup.py install --use-cxx11-abiSo, here my question is do I still need to install all those or am I good to go with the above installation?
https://pytorch.org/TensorRT/tutorials/installation.html
I'm still clear with the instruction document to install torch_tensorrt.
it would really help me and others to understand?
@dignakov if possible could you please put down a step by step to install for python API.
dignakov commentedon Jun 19, 2022
Unless you'd like to build everything from source, you should be okay just with the "Precompiled Binaries" section. That's everything you need for the "Python API", if you can
import torch_tensorrtand use it, you shouldn't need to do anything else.The section you're talking about is titled "Compiling From Source", and that's for building everything from scratch . . .
IamExperimenting commentedon Jun 19, 2022
@dignakov thanks very much for your support.
IamExperimenting commentedon Jun 20, 2022
@dignakov I'm still facing the error
ERROR: [Torch-TensorRT] - Cannot get current deviceIamExperimenting commentedon Jun 20, 2022
I'm still facing an error, I followed the instruction you provided earlier.
as a first step :
Step: 2

I download the CUDNN from the link which you provided https://developer.nvidia.com/rdp/cudnn-download
name of the .deb file
cudnn-local-repo-ubuntu2004-8.4.1.50_1.0-1_amd64.debthen I ran the below command
sudo dpkg -i cudnn-local-repo-ubuntu2004-8.4.1.50_1.0-1_amd64.debafter running that I get the below error.
narendasan commentedon Jun 20, 2022
Are you trying to setup cuda or cudnn?
IamExperimenting commentedon Jun 20, 2022
@narendasan I'm trying to setup CUDA, CUDNN and TensorRT. Finally, to install torch_tensorrt.
github-actions commentedon Sep 21, 2022
This issue has not seen activity for 90 days, Remove stale label or comment or this will be closed in 10 days
narendasan commentedon Dec 15, 2022
Can you try installing the latest package, as long as you have cuda installed all other dependencies will get installed for you via pip. If the issue persists reopen the issue.