AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.72k stars 7.96k forks source link

Extremely slow when using DLL library #3795

Open arachchi opened 5 years ago

arachchi commented 5 years ago

Hi @AlexeyAB

I have integrated https://pjreddie.com/darknet/ darknet with my project. It gives me around 35 FPS. I want to increase the frame rate using your implementation but with the DLL integration, I am getting only 14 FPS.

--Environment OS: Windows 10 GPU : RTX 2070 Cuda version : Cuda 10.1 latest Opencv : 3.4.2 CuDNN : cudnn-10.0-windows10-x64-v7.4.1.5

I followed the steps and got these results. First, I built the source code using CMAKE-GUI setting x64 and could run the program darknet.exe around 50 FPS. After that, I tried to integrate your darknet to my codebase using DLL and libs. So I used yolo_cpp_dll.sln with x64 and Release and built the yolo_cpp_dll and successfully integrated with my project. But it gave me 0.07 s just to run the detect method in one detection iteration. that means the processing time is around 14 FPS. Then I ran the python darknet_video.py to check the frame rate again. It gave me around 11 FPS.

Why DLL is significantly slower than the standalone application speed?

I am very grateful if you can provide me your recommendation to identify and fix the issue.

Thank you.

keko950 commented 5 years ago

Python is always slower than c/c++. You should use C if you want the same framerate as the standlone. Also, 14 fps is too low even for using python, check again your code and make sure you are not messing up somewhere, and remember to use numpy to threat arrays.

AlexeyAB commented 5 years ago

Why DLL is significantly slower than the standalone application speed?

Because your application (that uses dll) is slow, because you don't use multithreading

dreambit commented 5 years ago

@arachchi hi, i am also using python + dll import, it is relatively slow in my view. I run 3 instances of python and get about 40-50 fps but i am shure i could get more fps with my rtx 2070 with darknet.exe or c/c++ Let me know plz if u address this issue

arachchi commented 5 years ago

@dreambit As Alexy mentioned my CUDNN and CUDNN_HALF were not enabled. I used cmake-gui to create the project. After creating I had to enable those parameters manually in the preprocessor definitions. Please check your preprocessor definitions if you encounter this issue again. sorry for the late reply.