1
votes

I have two GPUs : Intel HD and nVidia Quadro. Using GPU Caps Viewer, I can detect my both GPUs in the OpenCL tab. However, by executing this code I am only getting the Intel one:

cv::ocl::setUseOpenCL(true);
if (!cv::ocl::haveOpenCL()) {
    std::cout << "OpenCL is not available..." << std::endl;
}
cv::ocl::Context context;
if (!context.create(cv::ocl::Device::TYPE_ALL)) {
    std::cout << "Failed creating the context..." << std::endl;
}
std::cout << context.ndevices() << " GPU devices are detected." << std::endl; 
for (int i = 0; i < context.ndevices(); i++) {
    cv::ocl::Device device = context.device(i);
    std::cout << "name:              " << device.name() << std::endl;
    std::cout << "available:         " << device.available() << std::endl;
    std::cout << "imageSupport:      " << device.imageSupport() << std::endl;
    std::cout << "OpenCL_C_Version:  " << device.OpenCL_C_Version() << std::endl;
    std::cout << std::endl;
}

Results:

1 GPU devices are detected.
name:              Intel(R) HD Graphics P530
available:         1
imageSupport:      1
OpenCL_C_Version:  OpenCL C 2.0

Information:

  1. Windows 10
  2. OpenCV 3.1
  3. Visual studio 2013
  4. nVidia Quadro M4000M

Notes:

  1. I am able to call my nVidia GPU directly using the OpenCV Cuda Interface.
  2. I have just installed the latest driver from nVidia website.
1
I am facing the same issue. Did you find any solution to this?Anirudh GP
Yes, just forget everything about contexts and put this environment variable :OPENCV_OPENCL_DEVICE=NVIDIA:GPU:Humam Helfawi
That worked. Thanks !Anirudh GP

1 Answers

0
votes

The solution in my case was to add this environment variable:

OPENCV_OPENCL_DEVICE=NVIDIA:GPU: