rbgirshick / py-faster-rcnn

Faster R-CNN (Python implementation) -- see https://github.com/ShaoqingRen/faster_rcnn for the official MATLAB version
Other
8.1k stars 4.11k forks source link

Network detection runs on CPU through ROS #286

Open CWOA opened 8 years ago

CWOA commented 8 years ago

Hi there,

I'm trying to test my trained network for object detection through ROS. I have a node (python file) running with many similarities to demo.py. Included in the class are commands to execute the network detection on the GPU, however, looking at recall times (~26s) and the system profiler it's clear the network is running on the CPU. Is there a way to get around this or is it just a limitation of ROS?

Thanks, Will

hgaiser commented 8 years ago

Yes... we ran into the exact same thing. I'm assuming you're calling the network in a ROS service call. Apparently these run in separate threads and only the thread that initialized the communication to the GPU can access it. In the end we added a thread for all caffe related work, initialized the network within that thread and when we wanted to detect something, let that be run in that separate thread too. (we used from concurrent.futures import ThreadPoolExecutor, it's up to you how you want to implement this)

CWOA commented 8 years ago

Thanks, that seems like a better solution than my current fix so I may swap over to that at some point. My current solution is the network detection callback function modifies a global variable which is checked continually by the main thread and invoked there instead.

sbargoti commented 8 years ago

Had a same problem. I was running caffe.set_mode_gpu() during the initialisation but found that the prediction was still very slow and the network was working on the CPU. The 'hacky' (but easy) solution was the re-run caffe.set_mode_gpu() before every call to the function im_detect, which takes in the net and the image for processing.

soulslicer commented 7 years ago

nice..same bug today. took me 3 hours to come to this conclusion.

mammadjv commented 6 years ago

@sbargoti thanks!