Ask Your Question
1

OCL error - assertion failed

asked 2013-03-12 03:58:17 -0500

mada gravatar image

Hi,

I´m working on OpenCV 2.4.4(C++), built using CMAKE with OCL support.

  • GPU - NVIDIA GeForce 9800 GT

  • CPU - AMD Opteron 252 (2 processors)

Code compiles with no errors, but during runtime I get this error (tried surf_matcher and squares samples):

OpenCV Error: Assertion failed ((localThreads[0] <= clCxt->impl->maxWorkItemSize s[0]) && (localThreads[1] <= clCxt->impl->maxWorkItemSizes[1]) && (localThreads[ 2] <= clCxt->impl->maxWorkItemSizes[2]) && ((localThreads[0] * localThreads[1] * localThreads[2]) <= kernelWorkGroupSize) && (localThreads[0] * localThreads[1] * localThreads[2]) <= clCxt->impl->maxWorkGroupSize) in unknown function, file . .....\modules\ocl\src\initialization.cpp, line 553

Also, while trying to run CUDA code for surf_matcher, I got runtime error saying:

"Too many resources requested for launch."

Anyone encountered this kind of problems? Could it be a GPU issue or OpenCV/OpenCL installation related? Thanks.

edit retag flag offensive close merge delete

Comments

2

It is GPU issue. Try to decrease input source resolution.

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2013-03-12 04:11:20 -0500 )edit

I´ve tried with smaller images if that´s what you meant, but did not help with OCL or CUDA. There are also some restrictions on how small the image can actually be so I could not try some really small values. I have forgot to mention, CUDA worked with some samples though, but not with surf_matcher that I need.

mada gravatar imagemada ( 2013-03-12 04:48:01 -0500 )edit

Could you specify exactly which function throws this error?

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2013-03-12 05:05:19 -0500 )edit

I am using surf_matcher example, error occurs while using: surf(img1, oclMat(), keypoints1GPU, descriptors1GPU); . And happens inside cv::ocl::openCLVerifyKernel function of initialization.cpp file. Hope that helps.

mada gravatar imagemada ( 2013-03-12 05:20:51 -0500 )edit

From what I can see, kernelWorkGroupSize is 128, and localThreads[0,1,2] - 256,1,1. Which seems to be the problem. My GPUs MAX_WORK_GROUP_SIZE is 512, so I am not sure are those numbers related and can I fix it somehow.

mada gravatar imagemada ( 2013-03-12 05:37:03 -0500 )edit

So, if it is a GPU problem, is there a way to fix it?

mada gravatar imagemada ( 2013-03-12 07:46:42 -0500 )edit

Did you find a fix to this? I have the same problem.

Chasseur gravatar imageChasseur ( 2013-11-25 11:08:09 -0500 )edit

Any fix to this? I have the same problem

Anirudh GP gravatar imageAnirudh GP ( 2016-12-09 01:15:37 -0500 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2016-12-09 04:47:46 -0500

The problem is that it is trying to use the Intel GPU instead of the Nvidia GPU. I solved this by choosing the Nvidia GPU as the OpenCL Device.

You can use this code to see what devices are present and then choose the right one :

cv::ocl::DevicesInfo devInfo;
int res = cv::ocl::getOpenCLDevices(devInfo);
if (res == 0)
{
    std::cerr << "There is no OPENCL Here !" << std::endl;
}
else
{
    for (unsigned int i = 0; i < devInfo.size(); ++i)
    {
        std::cout << "Device : " << devInfo[i]->deviceName << " is present" << std::endl;
    }
}
cv::ocl::setDevice(devInfo[1]);

Use the setDevice() function to set it to the Nvidia GPU

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-03-12 03:58:17 -0500

Seen: 920 times

Last updated: Dec 09 '16