【问题标题】:OpenCV gives Assertion failed error when running on GPU using OpenCL使用 OpenCL 在 GPU 上运行时,OpenCV 会出现 Assertion failed 错误
【发布时间】:2016-12-09 18:56:24
【问题描述】:

我有一个Nvidia GTX 970M GPU,我正在尝试在 c++ 中运行一个使用 OpenCL 在 GPU 上运行的人脸检测算法。

出现这个错误的函数是:

    ocl::OclCascadeClassifier::detectMultiScale()

我得到的错误是:

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

我知道这个问题与设备的 GPU 有关,但我不知道如何解决。我尝试过使用 OpenCV 版本 2 和 3,但都出现了同样的问题。

【问题讨论】:

    标签: c++ opencv opencl


    【解决方案1】:

    问题在于它试图使用 Intel HD Graphics GPU 而不是 Nvidia GPU。我通过选择 Nvidia GPU 作为 OpenCL 设备解决了这个问题。

    我使用的代码是:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-12
      • 2023-02-19
      • 1970-01-01
      • 2021-06-26
      • 2019-06-26
      相关资源
      最近更新 更多