Build OpenCV with OpenCL support

asked 2017-01-01 05:48:05 -0500

Suraksha gravatar image

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?

edit retag flag offensive close merge delete

Comments

No idea where is your problem. Can you give system and opencv version?

First what is your code test?

I have check my configuration with an nvidia card. I have set a break point at line https://github.com/opencv/opencv/blob... and line https://github.com/opencv/opencv/blob... (amd device). For my nvidia card nvcompiler.dll is loaded at line https://github.com/opencv/opencv/blob.... If dll is not found retval!=CL_SUCESS program go to https://github.com/opencv/opencv/blob.... May be you can check your program behaviour.

LBerger gravatar imageLBerger ( 2017-01-01 07:04:53 -0500 )edit

Thanks for your reply. I am using the latest version of OpenCV from github. I am using face_detection sample code and replaced Mat with UMat.The breakpoint at this line is triggered. but retval is 0.

I tried on both AMD processor + Carrizo also on Intel processor + Nvidea Graphics in windows 10 and windows 7. No performance improvement anywhere. How did you get nvcompiler.dll ? I installed AMD-APP-SDK like said in question above, but that didn't help me. also tried installing Intel OpenCL SDK & INtel OpenCL Runtimes..No luck with that as well.

Suraksha gravatar imageSuraksha ( 2017-01-03 04:13:09 -0500 )edit

I use nvidia card with nsigh and vs 2015. To test opencl you can use this program

LBerger gravatar imageLBerger ( 2017-01-03 10:41:01 -0500 )edit

Thank you. I tried test opencl code and it gave excellent results. Can you please explain this line in testOCL_OCV32.cpp. I understood that m is the average time taken, but sqrt(v) has +/- what does the value indicate and why v is required?

Suraksha gravatar imageSuraksha ( 2017-01-06 04:05:13 -0500 )edit
1

v2 is variance and sqrt(v2) standard deviation.It means that times to execute process is in interval [m-v m+v] with a probability of 66% if it is a gaussian distribution (it is not a gaussian distribution!) with 100 trial times consumming to execute algorithm is not a constant

LBerger gravatar imageLBerger ( 2017-01-06 10:10:45 -0500 )edit

Hi All, when I try to compile OpenCV 3.4.3 with OpenCL support it gives me compilation error around 35% saying:

fatal error: CL/cl.h: No such file or directory

I also get the following warnings while generating makefile:

Cannot generate a safe linker search path for target example_opencl_opencl-opencv-interop because files in some directories may conflict with libraries in implicit directories:

link library [libOpenCL.so] in /usr/lib/x86_64-linux-gnu may be hidden by files in: /usr/local/cuda/lib64

Does it make sense that OpenCL from Intel and from Cuda conflicts with each other ?

Zari gravatar imageZari ( 2018-11-15 04:05:58 -0500 )edit

@Zari, please don't post answers here, if you have a question or comment, thank you.

berak gravatar imageberak ( 2018-11-15 04:07:25 -0500 )edit