FEARTracker icon indicating copy to clipboard operation
FEARTracker copied to clipboard

How to convert model to TRT

Open fffffq99 opened this issue 2 years ago • 3 comments

Hello again. as you mentioned in the another issue, i tried to convert your model to TRT with torch2trt. here is a part of my code: dummy_input_to_model_init_encoder = torch.ones((1, 3, 128, 128)).cuda() dummy_input_to_model_update_search = torch.ones((1, 3, 256, 256)).cuda() model_encoder_update = torch2trt(model, [dummy_input_to_model_update_search, dummy_input_to_model_init_encoder])

after execution i got the following error: TypeError: forward() takes 2 positional arguments but 3 were given.

how to fix it?

fffffq99 avatar Nov 04 '22 14:11 fffffq99

well i finally converted model to trt but gives me this error: [TensorRT] ERROR: 4: (Unnamed Layer* 325) [Convolution]: count of 2304 weights in kernel, but kernel dimensions (3,3) with 256 input channels, 256 output channels and 1 groups were specified. Expected Weights count is 256 * 3*3 * 256 / 1 = 589824

fffffq99 avatar Nov 04 '22 15:11 fffffq99

also after converting model with torch2trt, model's accuracy drops heavily. why??!!

fffffq99 avatar Nov 05 '22 05:11 fffffq99

Hi

[TensorRT] ERROR: 4: (Unnamed Layer* 325) [Convolution]: count of 2304 weights in kernel, but kernel dimensions (3,3) with 256 input channels, 256 output channels and 1 groups were specified. Expected Weights count is 256 * 3*3 * 256 / 1 = 589824

Model runs correctly in PyTorch, so any errors in other runtimes come from the wrong conversion between runtimes. Make sure you didn't make errors in the model while converting it. I haven't tried converting FEAR to TensorRT using torch2trt. Try this TensorRT compiler for PyTorch, I converted FEAR to TensorRT using it a while ago.

also after converting model with torch2trt, model's accuracy drops heavily

It means your model is converted incorrectly. TensorRT should have the same accuracy if you convert all layers properly

borsukvasyl avatar Nov 08 '22 11:11 borsukvasyl

@t-martyniuk When can you release the code?

assertdebug avatar Jun 06 '24 11:06 assertdebug