luca-medeiros / lang-segment-anything

SAM with text prompt
Apache License 2.0
1.62k stars 174 forks source link

Speed improvement #29

Closed pwichmann closed 11 months ago

pwichmann commented 1 year ago

🚀 Feature

Is there a way to speed up the segmentation process?

Motivation & Examples

I noticed that my machine was not utilised much (GPU utilization < 20%, RAM and CPU were used to an even lesser degree) but segmenting a single large image took > 90 seconds. That is way too long for segmenting a large number of images.

I would think that there must be enormous potential for speed ups.

pwichmann commented 1 year ago

Forgot to say THANK YOU for an awesome library!

luca-medeiros commented 1 year ago

90 sec indeed sounds like a lot. It takes 3s or less for me on T4 and A100. Mind sharing your specs and cuda version? I'm guessing you are running on a CPU by mistake.

Liquidmasl commented 12 months ago

90 sec indeed sounds like a lot. It takes 3s or less for me on T4 and A100. Mind sharing your specs and cuda version? I'm guessing you are running on a CPU by mistake.

I am indeed running on CPU, I get the message in the console that it is just running on CPU, but i am not sure whats the reason. after some searching around it seams i am using the wrong CUDA version? or just a different cuda version that which what version torch was built. Can you help me out how I could solve that? In the end I want to be able to run my segmentation code in a docker container

luca-medeiros commented 12 months ago

@Liquidmasl uninstall torch and torchvision, and install again with the right cuda version.

Liquidmasl commented 11 months ago

@Liquidmasl uninstall torch and torchvision, and install again with the right cuda version.

yeah i am a bit cautios with playing around with those versions, those changes dont quite like to stay in their own conda env somehow.

anyway i got it to run in docker, and now its crazy much faster, so thats nice!

luca-medeiros commented 11 months ago

Awesome! @Liquidmasl

Closing for now.

jwahnn commented 5 months ago

How did you guys make it use GPU? I am facing a situation where it takes 20-30 seconds to process one image.