简体   繁体   中英

OpenCV gives Assertion failed error when running on GPU using OpenCL

I have an Nvidia GTX 970M GPU & I am trying to run a face detection algorithm in c++ that runs on the GPU using OpenCL.

The function where this error occurs is :

    ocl::OclCascadeClassifier::detectMultiScale()

The error I get is :

OpenCV Error: Assertion failed (localThreads[0] * localThreads[1] * localThreads[2] <= kernelWorkGroupSize) in cv::ocl::openCLVerifyKernel

I know that this problem is related to the GPU of the device but I do not know how to fix this. I have tried using OpenCV versions 2 and 3 but both give the same problem.

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

The code I used was :

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]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM