NVIDIA-AI-IOT / torch2trt

An easy to use PyTorch to TensorRT converter
MIT License
4.55k stars 671 forks source link

DLA error when using torch2trt.torch2trt() for yolov7 #798

Open zhifeis opened 2 years ago

zhifeis commented 2 years ago

Hi,

I've been trying to convert a yolov7 model to tensorrt format but I get a bunch of the following printouts"


[08/30/2022-15:24:57] [TRT] [E] 3: [builderConfig.cpp::canRunOnDLA::382] Error Code 3: API Usage Error (Parameter check failed at: optimizer/api/builderConfig.cpp::canRunOnDLA::382, condition: dlaEngineCount > 0
)

and when the function tests the inference with the sample input and converted model i get:

Traceback (most recent call last):
  File "trt_convert_yolo.py", line 25, in <module>
    model_trt = torch2trt.torch2trt(model_w, [sample_data])
  File "/home/shinkei/.virtualenvs/dev/lib/python3.6/site-packages/torch2trt-0.4.0-py3.6.egg/torch2trt/torch2trt.py", line 739, in torch2trt
    outputs = module(*inputs)
  File "/home/shinkei/.virtualenvs/dev/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1120, in _call_impl
    result = forward_call(*input, **kwargs)
  File "trt_convert_yolo.py", line 20, in forward
    return self.model(x, False)
  File "/home/shinkei/.virtualenvs/dev/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1120, in _call_impl
    result = forward_call(*input, **kwargs)
  File "/home/shinkei/project/CV_pipeline/object_detection/models/yolo.py", line 319, in forward
    return self.forward_once(x, profile)  # single-scale inference, train
  File "/home/shinkei/project/CV_pipeline/object_detection/models/yolo.py", line 345, in forward_once
    x = m(x)  # run
  File "/home/shinkei/.virtualenvs/dev/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1120, in _call_impl
    result = forward_call(*input, **kwargs)
  File "/home/shinkei/project/CV_pipeline/object_detection/models/yolo.py", line 99, in forward
    y[..., 0:2] = (y[..., 0:2] * 2. - 0.5 + self.grid[i]) * self.stride[i]  # xy
  File "/home/shinkei/.virtualenvs/dev/lib/python3.6/site-packages/torch2trt-0.4.0-py3.6.egg/torch2trt/torch2trt.py", line 310, in wrapper
    converter["converter"](ctx)
  File "/home/shinkei/.virtualenvs/dev/lib/python3.6/site-packages/torch2trt-0.4.0-py3.6.egg/torch2trt/converters/getitem.py", line 30, in convert_tensor_getitem
    input_trt = input._trt
AttributeError: 'Tensor' object has no attribute '_trt'

I suspect it's some missing layers that didn't make it during the conversion process since they were unsupported, but I have not been able to figure out exactly which layers are causing this. Can someone help me on this?

Nullray commented 1 year ago

I have the same problem. Waiting for a solution.

lothlorien13 commented 1 year ago

I have the same problem

Karn7276 commented 1 year ago

I have the same error for yolov5l

pjg205 commented 1 year ago

Hello, I have the same problem. Isn't there any solution yet?

pramodhrachuri commented 1 year ago

Any solution yet?