OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.64k stars 2.19k forks source link

object detection yolov3 model not using gpu? #689

Open drakorg opened 3 years ago

drakorg commented 3 years ago

Hi, I'm running latest version of imageai, tensorflow 2.50 and keras 2.5.0. On this machine I have a 3090 and a 1080 ti.

from imageai.Detection import ObjectDetection detector = ObjectDetection() detector.setModelTypeAsYOLOv3() detector.setModelPath('models/yolo.h5') detector.loadModel()

During the setup both GPUs are detected with no problem, all cuda libs loaded successfully and everything looks great. The 3090 gpu (index 0) reserves all its memory for the tensorflow session (I'll deal with that later), but everything seems to be in great shape. However, inferences are taking more than 4 seconds per frame. When looking at nvidia-smi usage GPU usage stays around 0% during those 4 seconds, but CPU usage jumps to 100% (via top command). It's obvious to me that despite everything looking good with the gpus, the inference is done on CPU.

I've searched in the yolo implementation sources and I've found not a single reference to the word "gpu". However I have found such references in retinanet implementation sources.

So, my question is:

Does imageai yolo implementation make use of the gpu at all? If so, do you have any idea on how to troubleshoot why it's not using it?

Thanks. Best regards.

Zordiac commented 3 years ago

You need to use the tensorflow_gpu instead of the tensorflow package.

drakorg commented 3 years ago

I am. Resnet inference times are in line to what'd be expected for gpu usage, around 30ms, but Yolo model isn't, taking more than 4 full seconds per frame. Both things on the very same machine.

On Sun, 15 Aug 2021 at 15:14 Zordiac @.***> wrote:

You need to use the tensorflow_gpu instead of the tensorflow package.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/OlafenwaMoses/ImageAI/issues/689#issuecomment-899090865, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACK2RE6VMHZQH3IHPSLDVBLT477XRANCNFSM5BNXXFGQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

rmeertens commented 3 years ago

Same problem here :) Let me know if you find a solution.

Fhwang0926 commented 3 years ago

i have same issue

708