Suraksha Ajith
Suraksha Ajith

Reputation: 892

Build OpenCV with OpenCL support

in CMake, I built OpenCV with OpenCL Enable ON(It automatically detected the OPENCL_INCLUDE_DIR path but the OPENCL_LIBRARY was empty, even after clicking config. for OPENCL_LIBRARY i don't see browse button either .. after generating opencv binaries then i run the below code

#include <iostream>
#include <fstream>
#include <string>
#include <iterator>
#include <opencv2/opencv.hpp>
#include <opencv2/core/ocl.hpp>

int main()
{
  if (!cv::ocl::haveOpenCL())       
      cout << "OpenCL is not avaiable..." << endl;          
   else cout << "OpenCL is AVAILABLE! :) " << endl; //this is the output

   cv::ocl::setUseOpenCL(true);

   cout << context.ndevices() << " GPU devices are detected." << endl; 
   for (int i = 0; i < context.ndevices(); i++)
   {
     cv::ocl::Device device = context.device(i);
     cout << "name:              " << device.name() << endl;
     cout << "available:         " << device.available() << endl;
     cout << "imageSupport:      " << device.imageSupport() << endl;
     cout << "OpenCL_C_Version:  " << device.OpenCL_C_Version() << endl;
     cout << endl;
    } //this works & i can see my video card name & opencl version
    cv::ocl::Device(context.device(0));
}

When i make use of UMat to measure the performance, the performance with(UMat) or without(Mat) OpenCL did not make any difference.

I downloaded AMD-APP-SDK from this link and tried to build but there was no OpenCL binaries (instead i saw opengl dll files[glew32.dll & glut32.dll]. How do i build OpenCV with OpenCL by linking the OPENCL_LIBRARY?

Upvotes: 4

Views: 2500

Answers (1)

Biaspoint
Biaspoint

Reputation: 575

I believe you have OpenCL, hence the result of your call to haveOpenCL and from the version request. I'm not sure the results of your performance test equate that you don't have OpenCL.

If you want to understand OpenCL, I would take a step back and figure it out first and then try to understand OpenCV with it.

Your link didn't work, did you try this. It has a link to the current AMD APP SDK (3.0) I would go through that setup and make sure you can make the OpenCL samples build/work on your system and then you should be able to troubleshoot why it isn't working in OpenCV (if it truly isn't).

As to performance, well, it depends. Every time you send data to and from the the graphics card it comes at a cost; the Transparent API was designed to make that choice for you: if sending it to the card for faster processing is worth the trip there and back... if it is not worth the trip you will actually have poorer performance. Additionally, not all of the library will run on the GPU. See some of the explanation on opencv.org.

Upvotes: 1

Related Questions