We are using the cv::dnn::Net class from OpenCV to perform image processing.
Here is the framework of the code with an indication of what causes the break:
cv::dnn::Net NeuralNetwork;
...
// This works fine since it keeps OpenCV code running on the CPU
// NeuralNetwork.setPreferableTarget(cv::dnn::DNN_TARGET_CPU);
// This change leads to a segmentation fault since it allows OpenCV to use the GPU
NeuralNetwork.setPreferableTarget(cv::dnn::DNN_TARGET_OPENCL);
...
// Segmentation fault occurs here
NeuralNetwork.forward(PredictedBoxesAndMasks, OutputLayerNames);
Error:
Shader has too many instructions: 689 (maximum is 512)
Status -1016: Unknown OpenCL error
Failed to compile kernel:
BASIC_k7x7_cn3_g3_s2x2_d1x1_b0_in256x256_p2x2_num1_M8_activ0_eltwise0_FP32_4_1_1_1
(long list of OpenCL definitions)
errmsg: Segmentation fault
OpenCV recognizes the GPU and returns this information:
Vendor name: Vivante Corporation
Name: Vivante OpenCL Device GC2000.5108.0000
Driver version: OpenCL 1.1 V6.2.4.p4.190076
available: 1
Global Memory size: 67108864
Memory cache size: 4096
Memory cache type: 2
Local Memory size: 1024
Local Memory type: 2
Max Clock frequency: 528
Question:
How do I limit the number of instructions OpenCV/OpenCL is trying to issue to the GPU?
I haven't seen any other users have this specific problem. I am guessing it is not popular to run heavyweight neural networks on embedded systems.
Thanks for your time & help!