dnn module and cuda [closed]

asked 2018-05-13 17:52:15 -0600

holger gravatar image

updated 2018-05-13 20:33:16 -0600

berak gravatar image

Hello, if i will compile open cv with cuda support - will the dnn module benefit from it? Calls like

net.forward()

Thank you in advance + Greetings, Holger

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by holger
close date 2018-05-14 03:52:38.316889

Comments

in short -- no.

berak gravatar imageberak ( 2018-05-13 20:33:35 -0600 )edit

Well i assumed so after reading the code and seeing a cv::gpu::GpuMat. But i wanted to clarify - maybe i was overlooking something. Well thx for the clarification.

Ok so in general if i want to evaluate a dnn model and that should be fast - i would used them directly instead of going through open cv (but that worked nice for me).

I will make some further measurement (with and without cuda - with and without open cv dnn), i hope i can stick to open cv.

holger gravatar imageholger ( 2018-05-14 03:52:04 -0600 )edit

where's the GpuMat ?

berak gravatar imageberak ( 2018-05-14 04:24:03 -0600 )edit

Ok i reread my sentence - what i meant was "After reading the code" - and looking at the cuda example code for open cv ( cv::gpu::GpuMat). It really wrote this wrong.

So cuda support is not "transparent" - u need specialized code to gain from it. My current understanding.

holger gravatar imageholger ( 2018-05-14 05:54:43 -0600 )edit

ah, ok. there is indeed cuda support for many opencv algorithms, just not for the dnn. (and it's not planned to add it)

if you have a halfway decent GPU, you might want to try the opencl dnn backend.

So cuda support is not "transparent" - u need specialized code to gain from it

exactly.

berak gravatar imageberak ( 2018-05-14 05:59:23 -0600 )edit

Wait, wait a second berak. I can set a backend for dnn.

 net.setPreferableBackend()

You are saying opencl will use my gpu(wikipedia says it could do that )? I want to use my gpu - thats what i am trying to do(nice rhyme). Wikipedia suggest open cli provides you the level of transparency i was complaining about missing on cuda.

It has not to be cuda if something else works. I will give it a try and measure the results. I have a google cloud account on a strong machine, hope it produces reasonable results - wish me luck :-)

Thank you very much again - i hope i can stick to open cv for fast dnn evaluation, its nice and its working. I really prefer it to all the solutions i tried out yet(darknet(yolo), tensorflow(ssd)).

holger gravatar imageholger ( 2018-05-14 06:22:13 -0600 )edit

yea, nice rhyme ;)

and apologies, it's "target", not "backend", see e.g. here

berak gravatar imageberak ( 2018-05-14 06:30:48 -0600 )edit

Well ok - you are right.For the people reading this - the method for activating cli for dnn is like berak metioned

net.setPreferableTarget()

more precise

net.setPreferableTarget(1)
holger gravatar imageholger ( 2018-05-14 07:07:31 -0600 )edit