opencv: Mobilenet-SSD output error results with OpenCL

System information (version)
  • OpenCV => 3.4.0
  • Operating System / Platform => Windows 10 64 Bit
  • Compiler => Visual Studio 2015
  • Cmake => 3.9.6
Detailed description

I have tried to run this program, but the detection results of this program are wrong if I set “opencl” as true in

const char* params  
    = "{ help           | false | print usage         }"  
      "{ proto          | MobileNetSSD_deploy.prototxt | model configuration }"  
      "{ model          | MobileNetSSD_deploy.caffemodel | model weights }"  
      "{ camera_device  | 0     | camera device number }"  
      "{ video          |   1.jpg    | video or image for detection}"  
      "{ out            |       | path to output video file}"  
      "{ min_confidence | 0.2   | min confidence      }"  
      "{ opencl         | true | enable OpenCL }"  
;.

The following picture is detection result with OpenCL.
error
The dimension of Mat detection obtained with Mat detection = net.forward("detection_out"); is “1,1,100,7”. This is obviously wrong.
The inputBlob in net.setInput(inputBlob, "data"); has been checked, it is right.
I think the problem is in Mat detection = net.forward("detection_out");

However ,when I set net.setPreferableTarget(DNN_TARGET_CPU);,the detection result with CPU is right.
This is the right detection result. right

Besides, when I input VGG net 's prototxt and caffemodel instead, the detection result is also right.

Steps to reproduce

I download Mobilenet-ssd 's caffemodel and prototxt from here ,and they work well without OpenCL.

I build OpenCV with OpenCL, with caffe, without CUDA.
The process of building OpenCV goes well, no warnings ,no errors.
I have set OpenCV path and OpencL path properly in VS2015 setting.

What do I have to do to improve the speed of ssd with OpenCL?

I am looking forward to your reply. Thank you!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 23 (10 by maintainers)

Most upvoted comments

@yiran-THU

Check this.

https://github.com/01org/caffe/issues/101

Seems similar issue was resolved for Mobilenet SSD

OK, Thanks for the quick reply. Intel® Core™ i5-4460 is haswell platform, which is old. I need to find one hardware and debug.

@dkurt @alalek @atlury

Good news! It’s working! I have upgraded the driver of my iGPU to the latest version, which is 23_20_16_4901 . Then everything goes well.

The information in terminal window is:

[ INFO:0] Initialize OpenCL runtime...
OpenCV(ocl4dnn): consider to specify kernel configuration cache directory
                 via OPENCV_OCL4DNN_CONFIG_PATH parameter.
[ INFO:0] Successfully initialized OpenCL cache directory: C:\Users\yiran\AppData\Local\Temp\opencv\3.4.0\opencl_cache\
[ INFO:0] Preparing OpenCL cache configuration for context: Intel_R__Corporation--Intel_R__HD_Graphics_530--23_20_16_4901

21_20_16_4542

OpenCV’s build machines have this driver version: 23_20_16_4849 You can get updates here: https://downloadcenter.intel.com/product/80939/Graphics-Drivers

BTW, NVIDIA GPU would not work via OpenCL because current OpenCV DNN has optimizations with “Intel subgroups” extension requirement.

opencv_test_dnn

This is OpenCV test, just enable tests in CMake (BUILD_TESTS=ON), build target “opencv_test_dnn” and check for this binary in “bin” subdirectory.

BTW, “clinfo” output should be good too, but we need to know that GPU is selected by OpenCV (Intel iGPU or another CUDA device). Did you see lines like these (in sample terminal window):

[ INFO:0] Successfully initialized OpenCL cache directory: /build/.cache/opencv_opencl_cache_x64/
[ INFO:0] Preparing OpenCL cache configuration for context: Intel_R__Corporation--Intel_R__HD_Graphics--r5_0_63503

@dkurt

Driver version = r4.0.59481

Please update to the latest OpenCL runtime (r5.0 from July 2017)