Replies: 2 comments 3 replies
-
Instead of YOLOv5 class, can you try with model=yolov5.load() ? YOLOv5 class from this repo is deprecated. Furthermore, when you provide image path instead of image numpy/torch array, the reading time from the disk will be the bottleneck instead of the infetence time. To overcome this issue I suggest you to update your benchmark script so that it does not include the image reading time. Have you compared the same with original ultralytics implementation of hub inference? Can you also paste your inference time results so that I can understand the issue you are pointing out? Lastly batch inference is beneficial when you are utilizing a dataloader with num workers > 1. Otherwise loading/arranging the images might take more time than inference time. |
Beta Was this translation helpful? Give feedback.
-
The slowdown looks to also be present in the underlying Ultralytics implementation. My guess is that it is due to the complexity of the YoloV5 layers combined with the limited number of CUDA cores on the GTX 1060 6GB (1280). If all the CUDA cores are occupied in processing a single layer for inference on a single image, no free cores will be able to simultaneously operate on a second image if the batch consists of multiple images. For a GTX 1060 6GB, batch processing gives no speedup:
On a GTX 1060 6GB, this gives the following output:
|
Beta Was this translation helpful? Give feedback.
-
Hello,
I am not sure whether my code is incorrect, or whether YoloV5 may have an error. In particular, inference time per image is roughly constant, regardless of whether the images are passed to YoloV5 through a batch or one by one. Batching images for YoloV5 inference gives little benefit. I have attached a simple demo script which can be copy/pasted and run to verify.
I am using a 6GB 1060 NVIDIA GPU, with 12 cores and plenty of memory. Thank you so much for taking a look, I really appreciate it, and I believe this might be an issue many users are running into.
Beta Was this translation helpful? Give feedback.
All reactions