Assertion failure using TAPI (cv::UMat) with big images

asked 2016-04-11 07:46:26 -0500

Finfa811 gravatar image

updated 2016-04-12 01:52:14 -0500

Hi,

I get an assertion failure when using the TAPI (cv::UMat) in the following code:

        for (int i = 0; i < N; ++i) {
            cv::extractChannel(img_vec[i], alpha_vec[i], 3);
            cv::cvtColor(img_vec[i], img_vec[i], CV_BGRA2BGR);
        }

Code is crashing in the fifth iteration, just after running cv::cvtColor(img_vec[i], img_vec[i], CV_BGRA2BGR).

The output message is:

OpenCV Error: Assertion failed (clEnqueueReadBuffer(q, (cl_mem)u->handle, CL_TRUE, 0, u->size, alignedPtr.getAlignedPtr(), 0, 0, 0) == CL_SUCCESS) in map, file C:\OpenCV-3.1.0\sources\modules\core\src\ocl.cpp, line 4758

This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. terminate called after throwing an instance of 'cv::Exception' what(): C:\OpenCV-3.1.0\sources\modules\core\src\ocl.cpp:4758: error: (-215) clEnqueueReadBuffer(q, (cl_mem)u->handle, CL_TRUE, 0, u->size, alignedPtr.getAlignedPtr(), 0, 0, 0) == CL_SUCCESS in function map

It only happens with big images (> 40Mp). The code is working if I don't use the TAPI (cv::Mat) or disabling OpenCL (cv::ocl::setUseOpenCL(false)).

Why is this so? Is there any way to make it work with GPU support?

edit retag flag offensive close merge delete

Comments

1

Well probably the image is too large to get processed inside your GPU dedicated memory, which can be expected by high resolution images. What I used to do to solve this is splitting the image beforehand and passing the parts one by one to the GPU function. However, you might discover that the bottleneck of passing data to GPU is more time consuming then just running it multicore on the CPU.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-04-11 07:53:02 -0500 )edit

I don't think that is the problem, memory should be large enough to process such images. Here is an output of my device info:

  • CL_DEVICE_NAME: GeForce GTX 970M
  • CL_DEVICE_IMAGE2D_MAX_WIDTH: 16384x16384
  • CL_DEVICE_IMAGE3D_MAX_WIDTH: 4096x4096x4096
  • CL_DEVICE_MAX_PARAMETER_SIZE: 4352
  • CL_DEVICE_MAX_MEM_ALLOC_SIZE: 805306368
  • CL_DEVICE_GLOBAL_MEM_SIZE: 3221225472
  • CL_DEVICE_GLOBAL_MEM_CACHE_SIZE: 163840
  • CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 65536
  • CL_DEVICE_LOCAL_MEM_SIZE: 49152
Finfa811 gravatar imageFinfa811 ( 2016-04-12 01:49:19 -0500 )edit