torch2trt icon indicating copy to clipboard operation
torch2trt copied to clipboard

AttributeError: 'Tensor' object has no attribute '_trt'

Open astekardis opened this issue 4 years ago • 8 comments

I'm currently trying to use torch2trt on my Jetson Nano. See below for the jetson_release info for this device:

 - NVIDIA Jetson Nano (Developer Kit Version)
   * Jetpack 4.4 DP [L4T 32.4.2]
   * NV Power Mode: MAXN - Type: 0
   * jetson_clocks service: inactive
 - Libraries:
   * CUDA: 10.2.89
   * cuDNN: 8.0.0.145
   * TensorRT: 7.1.0.16
   * Visionworks: 1.6.0.501
   * OpenCV: 4.1.1 compiled CUDA: NO
   * VPI: 0.2.0
   * Vulkan: 1.2.70

Note that I've confirmed that the sample usage code given here runs without issue on this device.

I've cloned torch2trt and installed it with plugin support on my Nano, but am unable to successfully to convert my object detection pytorch model to a TensorRT engine. Specifically, the error that returns when I call model_trt = torch2trt(model, [x]) is as follows:

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    model_trt = torch2trt(retinanet, [x])
  File "/usr/local/lib/python3.6/dist-packages/torch2trt/torch2trt.py", line 377, in torch2trt
    outputs = module(*inputs)
  File "/home/nvidia/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/nvidia/projects/object_detection/retinanet/model.py", line 259, in forward
    transformed_anchors = self.regressBoxes(anchors, regression)
  File "/home/nvidia/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/nvidia/projects/object_detection/retinanet/utils.py", line 104, in forward
    widths  = boxes[:, :, 2] - boxes[:, :, 0]
  File "/usr/local/lib/python3.6/dist-packages/torch2trt/torch2trt.py", line 202, in wrapper
    converter['converter'](ctx)
  File "/usr/local/lib/python3.6/dist-packages/torch2trt/converters/getitem.py", line 31, in convert_tensor_getitem
    input_trt = input._trt
AttributeError: 'Tensor' object has no attribute '_trt'

Since the error appears to be with the getitem converter, I tried running python3 -m torch2trt.test --name=getitme from the top level torch2trt directory, but no output is printed.

What can I do to solve this issue?

astekardis avatar Jun 02 '20 01:06 astekardis

I encountered the same problem. Any solution?

yuzhiyiliu avatar Jul 09 '20 11:07 yuzhiyiliu

I encountered the same problem. Any solution?

Same problem with yours, solved?

Joevaen avatar Aug 10 '20 08:08 Joevaen

Any updates on this?

austinmw avatar Nov 23 '20 05:11 austinmw

same problem,who can solve it?@jaybdub

DWendou avatar Jun 22 '21 07:06 DWendou

same here

mlizhardy avatar Aug 19 '21 21:08 mlizhardy

Same problem, how did you able to solve it?

DuyguSerbes avatar Oct 21 '21 16:10 DuyguSerbes

same error, any updates?

yingzgigi avatar Mar 11 '22 03:03 yingzgigi

same

wyf-1996 avatar Apr 15 '22 13:04 wyf-1996