I have an issue when running darknet (built with jetpack Opencv) https://github.com/alexeyab/darknet on the jetson nano…(it is reproducible with any jetson or nvidia desktop GPU running darknet)
How to reproduce it:
- Flash fresh jetpack 4.2.2
- Get and compile darknet with the default OpenCV 3.3.1 with gstreamer support pre-installed with Jetpack
- Run darknet on a cam with this gstreamer pipeline: “v4l2src device=/dev/video0 ! video/x-raw, framerate=30/1, width=640, height=360 ! videoconvert ! appsink”
./darknet detector demo cfg/coco.data cfg/yolov3-tiny.cfg yolov3-tiny.weights "v4l2src device=/dev/video0 ! video/x-raw, framerate=30/1, width=640, height=360 ! videoconvert ! appsink" -ext_output -dont_show
When I do so, there is a big memory leak, RAM increase very fast until the nano crashes after a while. This can also be reproduced with this gstreamer input for raspberrypi cam:
"nvarguscamerasrc ! video/x-raw(memory:NVMM),width=1280, height=720, framerate=30/1, format=NV12 ! nvvidconv ! video/x-raw, format=BGRx, width=640, height=360 ! videoconvert ! video/x-raw, format=BGR ! appsink"
But this is not happening when using another input into darknet to get the webcam feed, which is:
./darknet detector demo cfg/coco.data cfg/yolov3-tiny.cfg yolov3-tiny.weights -c 0 -ext_output -dont_show
There doesn’t seem to be a leak happening…
So this doesn’t seem to be related with darknet, but with the OpenCV interface that feed the video stream into darknet.
This API is VideoCapture from OpenCV, and the only difference seems to be that when we input a Gstreamer pipeline, it uses:
VideoCapture::VideoCapture(const string& filename)
Whereas when we use a the -c 0 flag, it uses:
My guess is opencv uses Gstreamer for Video I/O if it is a Gstreamer pipeline input, otherwise it uses other Video I/O to hook directly to the webcam…
I might be wrong but I would say there is an issue with Gstreamer and OpenCV in this case, I tried to run on more recent version of OpenCV (compile it myself), but I always get this leak…
As Nvidia also use OpenCV in its Deepstream SDK … did you had issue with the VideoCapture API of OpenCV, any idea how might I solve this ?