Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FPS slow down #4

Open
AndrewSivrit opened this issue Feb 6, 2018 · 7 comments
Open

FPS slow down #4

AndrewSivrit opened this issue Feb 6, 2018 · 7 comments

Comments

@AndrewSivrit
Copy link

Hi @ganyc717
I find one more problem. After run
darknet_cl.exe detector demo data/voc.data yolo-voc.cfg yolo-voc.weights test.mp4
On the first frames I get 7,1 FPS, but after several minutes I get less 5 FPS.

@AndrewSivrit
Copy link
Author

If run to train speed of learning is slow down too

@Kylin-PHYTIUM
Copy link

The performance of CL is lower than corresponding CUDA implementation on the same device.
@ganyc717 @AndrewSivrit
I want to known that whether the code supports train yolo2 on multiple CL devices?

@ganyc717
Copy link
Owner

Hi @Kylin-PHYTIUM
I have checked the bottleneck, the performance blocked at BLAS library, I think nvidia has their own well optimization cuBLAS library which is about 3 times faster than clBLAS.
Currently multi device is not supported, maybe I will add support later.

@Bardo91
Copy link

Bardo91 commented Jun 14, 2018

The same issue happens to me. When I let it run for a while, the speed starts decreasing. Here I plot the times in microseconds over time for some of the required stages. All of them remain stable (img preparation, data copy, result copying etc...) but the prediction grows continuously.
image

To be exact, the call that grows in time is the call to the prediction of the net from the data, i.e. network_predict(net, X);.

Any clue?

@Bardo91
Copy link

Bardo91 commented Jun 14, 2018

Just to isolate the problem I observed what happens if I reload the "network *net" object each time I use it. Basically I call net = load_network(wStr1, wStr2, 0); at the beginning of the loop and free_network(net); at the end. It can be clearly seen in the following figure that the "slow down" does not happens if the network is reloaded:
image

Left figure shows that if the net is not reloaded, i.e. it is loaded just at the beginning (which is the logical behaviour), then the prediction time increases. However, right figure shows that if the net is reloaded each time, then no slow down can be observed, but obviously, loading the network takes a couple of seconds, so it is not a solution...
I will keep digging into the problem, I hope this helps to someone else too.

@Bardo91
Copy link

Bardo91 commented Jun 14, 2018

I am not an expert in neither YOLO nor CL, but while debugging a bit the code I found that the code that slows down over time is https://github.com/ganyc717/Darknet-On-OpenCL/blob/master/darknet_cl/src/network.cpp#L781. Particularly, using tiny_yolo_v2, the layer that causes the issue is the layer number 15, which seems to be the region_layer.... The deeper I went was this line

cl_int status = clEnqueueNDRangeKernel(*cl->queue, kernel, 3, NULL, global_size, NULL, NULL, NULL, &e);
. If I am not wrong, that line queue the call of the kernel, what can cause that continuous increment of time?

@Bardo91
Copy link

Bardo91 commented Jun 15, 2018

I modified the code to enable CL_QUEUE_PROFILING_ENABLE. Then I added the following lines to profile the enqueue call:

cl_ulong time_start;
cl_ulong time_end;
clGetEventProfilingInfo(e, CL_PROFILING_COMMAND_START, sizeof(time_start), &time_start, NULL);
clGetEventProfilingInfo(e, CL_PROFILING_COMMAND_END, sizeof(time_end), &time_end, NULL);
double nanoSeconds = time_end-time_start;
printf("OpenCl Execution time is: %0.3f milliseconds \n",nanoSeconds / 1000000.0);

These measures of time remain stable... which confuses me more. It seems that the GPU run it self takes the same time, but when the measure of the cpu call it grows in time:

clock_t t1 = clock();
cl_event e;
cl_int status = clEnqueueNDRangeKernel(*cl->queue, kernel, 3, NULL, global_size, NULL, NULL, NULL, &e);
clock_t t2 = clock();
printf("enqueue : \t %f\n",(float)(t2 - t1) / CLOCKS_PER_SEC);

Bardo91 added a commit to Bardo91/Darknet-On-OpenCL that referenced this issue Jun 16, 2018
…th tiny yolov2.

The reason of the "hack" is extended in ganyc717#4. As a summary, the time expend in that layer was drastically increasing for some reason. Current version is stable and actually faster than GPU implementation in a MSI laptop with an i7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants