NVIDIA-AI-IOT / torch2trt

An easy to use PyTorch to TensorRT converter
MIT License
4.61k stars 677 forks source link

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

Open astekardis opened 4 years ago

astekardis commented 4 years ago

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?

yuzhiyiliu commented 4 years ago

I encountered the same problem. Any solution?

Joevaen commented 4 years ago

I encountered the same problem. Any solution?

Same problem with yours, solved?

austinmw commented 3 years ago

Any updates on this?

DWendou commented 3 years ago

same problem,who can solve it?@jaybdub

mlizhardy commented 3 years ago

same here

DuyguSerbes commented 3 years ago

Same problem, how did you able to solve it?

yingzgigi commented 2 years ago

same error, any updates?

wyf-1996 commented 2 years ago

same