Opencv_contrib: Goturn tracker fails to allocate 95GB of RAM

Created on 8 Feb 2020  路  9Comments  路  Source: opencv/opencv_contrib

System information (version)
  • OpenCV => 4.2.0
  • Operating System / Platform => Ubuntu 19.10 64bit
  • Compiler => gcc 8
Detailed description

I have tried to use goturn tracker and it fails with error not being able to allocate 95GB of memory.
I have compiled the OpenCV with CUDA enabled flags, however goturn fails with the same error if I use non CUDA enabled OpenCV build

I have used caffe prototxt and caffemodel files available.

Steps to reproduce
Ptr<Tracker> tracker = TrackerGOTURN::create()
tracker->init(frame, bbox)'

Error

```.cpp terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.2.0) /home/mirko/programiranje/ocv42install/opencv/modules/core/src/alloc.cpp:73: error: (-4:Insufficient memory) Failed to allocate 95588562276 bytes in function 'OutOfMemoryError'

bug dnn (moved out)

Most helpful comment

Hi! As a temporal workaround please try to comment the following lines:

input: "data1"
# input_dim: 1
# input_dim: 3
# input_dim: 227
# input_dim: 227

input: "data2"
# input_dim: 1
# input_dim: 3
# input_dim: 227
# input_dim: 227

Sorry for inconvenience!

import numpy as np
import cv2 as cv

net = cv.dnn.readNet('goturn.prototxt', 'goturn.caffemodel')
inp0 = np.random.standard_normal([1, 3, 227, 227]).astype(np.float32)
inp1 = np.random.standard_normal([1, 3, 227, 227]).astype(np.float32)
net.setInput(inp0, "data1")
net.setInput(inp1, "data2")
net.forward()

All 9 comments

Having the same issue with python as well. Same OpenCV version.

  • OS: Arch Linux 64bit
  • OpenCV: 4.2.0
  • Cuda: V10.2.89

I wonder what other similarities we have, we appear to be the other ones having this specific issue.

Tested:

  • OpenCV: 3.4.8.29 Ran for a short time as expected then hit another memory error.

So it appears that the bounding box is growing large enough to cause the memory issue. I'm going to try to limit its size and see if that fixes the issue (no clue how to actually do that).

  • Update: I put some limits on the box size by setting a new tuple once a limit was reached. It did prolong the display time but once the tracker lost interest on the object the bounding box hit the limits and after a few seconds it crashed with the same error. Only working with version 3.4.8.29 for me. I haven't tried an earlier version yet.

the culprit of the problem for OpenCV 4.2.0 is not in inference itself. Loading caffe model causes the error. It doesn't reach the inference at all.

Works fine with python2.7 and openCV3.X.X

Loading caffe model causes the error.

can be reproduced with opencv4.x like:

net = cv2.dnn.readNet("goturn.caffemodel", "goturn.prototxt")

Same issue with python as well :

OS: Arch Windows 64bit
OpenCV: 4.2.0

Any idea on how to fix this ?

Please try patch from here: https://github.com/opencv/opencv/pull/16617

Hi! As a temporal workaround please try to comment the following lines:

input: "data1"
# input_dim: 1
# input_dim: 3
# input_dim: 227
# input_dim: 227

input: "data2"
# input_dim: 1
# input_dim: 3
# input_dim: 227
# input_dim: 227

Sorry for inconvenience!

import numpy as np
import cv2 as cv

net = cv.dnn.readNet('goturn.prototxt', 'goturn.caffemodel')
inp0 = np.random.standard_normal([1, 3, 227, 227]).astype(np.float32)
inp1 = np.random.standard_normal([1, 3, 227, 227]).astype(np.float32)
net.setInput(inp0, "data1")
net.setInput(inp1, "data2")
net.forward()
Was this page helpful?
0 / 5 - 0 ratings