dnn setup problem

asked 2018-05-18 03:55:24 -0600

holger gravatar image

updated 2018-05-18 04:10:01 -0600

Hello,

I just upgraded my system to a new nvidea graphic card(gtx 1050 TI - windows7) and my example code which was reading a darknet model started crashing. The same program was running fine before and also still runs fine in the cloud(no gpu).

I am assuming something is wrong with my open-cl runtime? Any suggestions on this could be helpful. Thx a lot(i always run into complicated things) + Greetings, Holger

    String imageFilePath = "C:\\development\\opencvjava\\test.png";
    String modelConfiguration = "C:\\development\\opencvjava\\voc.cfg";
    String modelBinary = "C:\\development\\opencvjava\\yolov2-voc.weights";
    try {
        classNames = Files.readAllLines(Paths.get("C:\\development\\opencvjava\\voc.names"));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    // import the Caffe model
    net = readNetFromDarknet(modelConfiguration, modelBinary);
    System.err.println("Hello cloud---");

    Mat img = imread(imageFilePath);
    cvtColor(img, img, Imgproc.COLOR_BGRA2BGR);

    //read in blob
    Mat blob = blobFromImage(img, 1 / 255.F, new Size(416, 416), new Scalar(0), true, false);
    net.setInput(blob);

    // classify the image by applying the blob on the net
    long start = System.currentTimeMillis();
    //here program crashes
    Mat detectionMat = net.forward();//compute output
    long end = System.currentTimeMillis();
    System.err.println("net detection took: "+(end-start)+"ms");

Output

Process finished with exit code -1073740791 (0xC0000409)
edit retag flag offensive close merge delete

Comments

https://developer.nvidia.com/opencl "OpenCL support is included in the latest NVIDIA GPU drivers, available at www.nvidia.com/drivers"

So maybe the opencl version i got via the driver is incompatible? I am using open cv 3.4.1 binary.

holger gravatar imageholger ( 2018-05-18 04:00:34 -0600 )edit

A Restart fixed this(hand on head) But the detection times are now way worse than before (same machine - only new graphic card)

Before 257ms

Now 1569ms

I got the same hardware- same program - only new graphic card. I dont really understand this behaviour, can someone comment on this please? Is open cl deciding to use my gpu and its still to weak?

holger gravatar imageholger ( 2018-05-18 04:26:43 -0600 )edit

I wil try to further diagone - when downloading some sample from nvia and executing them i get.

C:\Users\Holger\Downloads\oclBandwidthTest\NVIDIA GPU Computing SDK\OpenCL\bin\Win32\Debug\oclBandwidthTest.exe Starting...

WARNING: NVIDIA OpenCL platform not found - defaulting to first platform! Error -1 in clGetDeviceIDs call !!!

I will try to get this to work and hope the opencv things fix with it.

holger gravatar imageholger ( 2018-05-18 04:45:08 -0600 )edit

OpenCL SDK samples included with NVIDIA GPU Computing SDK require a GPU with CUDA Compute Architecture to run properly. For a complete list of CUDA-Architecture compute-enabled GPUs, see the list online at: http://www.nvidia.com/object/cuda_lea...

https://developer.nvidia.com/cuda-gpusgtx 1050 is listed, but not gtx 1050 TI maybe thats the reason.

https://www.geforce.com/hardware/desk... states that cuda is supported - i will try download cuda sdk. Then i will compile with vs studio and try to get nvidea open cl example running.

Uiuiui

holger gravatar imageholger ( 2018-05-18 04:59:51 -0600 )edit

@holger, your code sample doesn't use OpenCL backend of dnn.

dkurt gravatar imagedkurt ( 2018-05-18 06:01:00 -0600 )edit

yes u are right and thank you for response, pasted wrong code - heres the current code - still my problem

holger gravatar imageholger ( 2018-05-18 06:47:53 -0600 )edit

Had problem pasting - here the current code

    //read model
    net = readNetFromDarknet(modelConfiguration, modelBinary);
    //set open cl
    net.setPreferableTarget(Dnn.DNN_TARGET_OPENCL);
    System.err.println("Hello cloud---");

    Mat img = imread(imageFilePath);
    cvtColor(img, img, Imgproc.COLOR_BGRA2BGR);

    //read in blob
    Mat blob = blobFromImage(img, 1 / 255.F, new Size(416, 416), new Scalar(0), true, false);
    net.setInput(blob);

    // classify the image by applying the blob on the net
    long start = System.currentTimeMillis();
    Mat detectionMat = net.forward();//compute output
    long end = System.currentTimeMillis();
    System.err.println("net detection took: "+(end-start)+"ms");
holger gravatar imageholger ( 2018-05-18 06:56:06 -0600 )edit

Output is

Hello cloud---
net detection took: 1456ms
[ INFO:0] Initialize OpenCL runtime...
holger gravatar imageholger ( 2018-05-18 06:59:21 -0600 )edit

my cuda sdk in the meantime means

Running on...

Device 0: GeForce GTX 1050 Ti Quick Mode

Host to Device Bandwidth, 1 Device(s) PINNED Memory Transfers Transfer Size (Bytes) Bandwidth(MB/s) 33554432 5368.1

Device to Host Bandwidth, 1 Device(s) PINNED Memory Transfers Transfer Size (Bytes) Bandwidth(MB/s) 33554432 5306.2

Device to Device Bandwidth, 1 Device(s) PINNED Memory Transfers Transfer Size (Bytes) Bandwidth(MB/s) 33554432 95144.6

Result = PASS

holger gravatar imageholger ( 2018-05-18 07:05:02 -0600 )edit

maybe compiling opencv could help - on ubuntu is was not that difficult.

holger gravatar imageholger ( 2018-05-18 07:12:11 -0600 )edit