OpenCV dnn, OpenCL and Nvidia graphic cards

asked 2019-09-23 04:38:09 -0500

teshansj gravatar image

I am a newbie to OpenCV. I have a vague question regarding the combination of dnn, OpenCL and Nvidia graphic cards. I have written a program using dnn darknet for YOLO object detection. Without setting any special flags, I simply do net = dnn::readNetFromDarknet(xxx) and do predictions which works fine using the CPU

I have a GeForce GTX 1070 and now I want to use it to optimize the detection time. But when I try to set DNN_TARGET_OPENCL for my net, it says

OpenCV(ocl4dnn): consider to specify kernel configuration cache directory 
                 via OPENCV_OCL4DNN_CONFIG_PATH parameter.
OpenCL program build log: dnn/dummy
Status -11: CL_BUILD_PROGRAM_FAILURE
-cl-no-subgroup-ifp

And it takes the same amount of time to process an image so I'm guessing OpenCL is not being used.

I am using OpenCV 4.1.1 compiled with WITH_CUDA=ON. I have cuDNN set up as well.

  1. What is the connection between OpenCL and dnn?

  2. How do I get my YOLO to use the graphic card and speed up the process?

edit retag flag offensive close merge delete

Comments

1) OpenCL is a vendor neutral implementation for gpu computation. DNN module DOES NOT use OpenCL - At least i could never see a difference.

2) Just use native yolo and put a (rest) service around it. Use OpenCV only for CPU.

holger gravatar imageholger ( 2019-09-23 16:57:23 -0500 )edit

Thanks @holger. What do you mean by put a rest service around it?

teshansj gravatar imageteshansj ( 2019-09-23 22:41:44 -0500 )edit

Use a micro service architecture - make a mini program with only the functionality needed and expose it to the outside so it can be used by other programs(language & platform neutral & easily testable - i hate spaghetti code).

One way to archieve this is to have a rest based service. So in your case maybe write a rest service which accept the image as raw data and gives back the result(bounding boxes is your case?). You can use any other communication method(amqp for example) as well. Thats all.

holger gravatar imageholger ( 2019-09-24 09:36:25 -0500 )edit
1

There is OpenCL DNN backend in OpenCV...

Show me a DNN library with OpenCL that can compete with CUDA :) For now, the only alternatives are the ROCm stack by AMD and the works done by Codeplay.

Have a look at this PR since you have a Nvidia card.

Eduardo gravatar imageEduardo ( 2019-09-26 15:25:53 -0500 )edit

Its not merged yet and open? :-( So i would need to build on feature branch? If this goes into master and working - this would be a wet dream for me(yes i am strange XD)

holger gravatar imageholger ( 2019-09-26 16:15:50 -0500 )edit

@holger It's in master now.

Yashas gravatar imageYashas ( 2019-10-26 22:59:10 -0500 )edit

Yes i saw on youtube(i was the commter there :-))- GJ!

holger gravatar imageholger ( 2019-10-27 12:00:53 -0500 )edit