OpenCV dnn, OpenCL and Nvidia graphic cards
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.
What is the connection between OpenCL and
dnn
?How do I get my YOLO to use the graphic card and speed up the process?
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.
Thanks @holger. What do you mean by put a rest service around it?
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.
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.
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 It's in master now.
Yes i saw on youtube(i was the commter there :-))- GJ!