cooperative-foundational-models icon indicating copy to clipboard operation
cooperative-foundational-models copied to clipboard

running inference on single image overloads gpu memory

Open shahyaan opened this issue 11 months ago • 3 comments

Hi,

When trying to run inference on a test image using your script I get a "CUDA out of memory error". My image size is 640x480, and I have a GPU with 24GB memory. I'd appreciate it if you could help me resolve this. Thanks!

shahyaan avatar Feb 29 '24 17:02 shahyaan

Hello,

Thanks a lot for your interest in our work.

I tested it out on a 24GB machine available to me, and unfortunately it does not run on it, and requires 40GB GPU machine to run.

However, I can suggest you to try removing one of the models like either GDINO or SAM, and see if it helps you?

In the main script, sam is initialized here: (you may also have to remove the usage of sam in other parts of the script in scripts/novel_object_detection/ground_dino_utils.py in the "inference_gdino" function too.

sam init: https://github.com/rohit901/cooperative-foundational-models/blob/fb45630c46d75f7a1856654665191aeddeb3eb98/scripts/novel_object_detection/main.py#L60

gdino init: https://github.com/rohit901/cooperative-foundational-models/blob/fb45630c46d75f7a1856654665191aeddeb3eb98/scripts/novel_object_detection/main.py#L51

rohit901 avatar Feb 29 '24 18:02 rohit901

Hi Rohit,

Thanks for the quick response. I tried what you suggested, but even disabling SAM and then also MaskRCNN models doesn't seem to help with GPU memory overruns.

shahyaan avatar Feb 29 '24 19:02 shahyaan

Did you try disabling GDINO itself, and using the SRM scores or refinement from SAM as it is? Depending on your use-case, it may still be helpful to you?

Otherwise, could you please try to run it on a 40GB machine? I've tested the code on 1x A100 as well which has 40GB VRAM.

rohit901 avatar Mar 01 '24 03:03 rohit901