TensorRT: Unable to use any Torch-TensorRT methods
I’m facing this error:
AttributeError: module ‘torch_tensorrt’ has no attribute ‘compile’
I also get this error when I try to use any other method like Input().
This is how I installed Torch-TensorRT:
pip install torch-tensorrt -f github.com/NVIDIA/Torch-TensorRT/releases
Code (from official documentation):
import torch_tensorrt
model = model.eval()
compile_settings = {
"input_shapes": [
{
"min": [1, 1, 16, 16],
"opt": [1, 1, 32, 32],
"max": [1, 1, 64, 64]
},
],
"op_precision": torch.half # Run with fp16
}
enabled_precisions = {torch.float, torch.half}
trt_ts_module = torch_tensorrt.compile(model, inputs=compile_settings, enabled_precisions=enabled_precisions)
Stack Trace:
AttributeError Traceback (most recent call last)
<command-3167120371910218> in <module>
14 enabled_precisions = {torch.float, torch.half}
15
---> 16 trt_ts_module = torch_tensorrt.compile(model, inputs=compile_settings, enabled_precisions=enabled_precisions)
AttributeError: module 'torch_tensorrt' has no attribute 'compile'
Please let me know how I can fix this issue.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 15
I’d recommend just downloading the appropriate wheel file and installing directly. If your python version isn’t between 3.6-3.9 that might cause the issue too.