Error [defaultAllocator.cpp::deallocate::35] Error Code 1: Cuda Runtime (invalid argument)

I have converted file into yolov5s.wts and then build the engine file yolov5s.engine. I have modified some parts of the code from here Jetson/L4T/TRT Customized Example - and some code taken from this repo tensorrtx/ at master · wang-xinyu/tensorrtx · GitHub . Everything is working fine but when I close the window by pressing Esc, it closes with error msg:

[03/30/2023-19:08:59] [TRT] [E] 1: [defaultAllocator.cpp::deallocate::35] Error Code 1: Cuda Runtime (invalid argument)

Tensor rt version:
Board Type: Jetson Nano
Cuda: 10.2.300
Jetpack: 4.6.1

I have uploaded my project here: - Google Drive
with all the files. Please if anyone can suggest what is the issue? Thanks


This is related to the destructor of TensorRT.
Could you try to unset the engine variable to see if it helps?

engine = []


Hi @AastaLLL
Where exactly I have to put this in code I shared?
I created another function in the class YoloV5TRT

def Destroy(self):
   self.engine = []

and called this outside of while display.IsStreaming(): so that once application closes, self.engine = [] is called but still getting the same error.


Hi, @AastaLLL is there any update on this, please? Thanks

Solved it by moving the below variable outside of the class



Sorry for the late reply.
Thanks for the update and good to know it works now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.