Giter Club home page Giter Club logo

Comments (7)

liutongkun avatar liutongkun commented on August 12, 2024

It seems that efficientSAM provided only works on CPU, I tried to use cuda() to move model and data to GPU , but it doesn't help a lot.

Also tried the seg-everything to cuda method in pull requests, doesn't help a lot as well.

Maybe the box-promted SAM needs a function like " predictor.set_image() " in SAM and Mobile-SAM to save time used in a same image.

I have found that GPU can effectively accelerate, with approximately 30-40ms per image on 3090ti. The problem is that the speed will be slower when running the first inference, I'm not sure why

from efficientsam.

yformer avatar yformer commented on August 12, 2024

@silinsi, it should very fast to run EfficientSAM on GPU. Can you share more information?

from efficientsam.

yformer avatar yformer commented on August 12, 2024

@liutongkun, for the first inference, loading the model to GPU and moving the data to GPU may take time. Can you share the latency for the first inference?

from efficientsam.

liutongkun avatar liutongkun commented on August 12, 2024

@liutongkun, for the first inference, loading the model to GPU and moving the data to GPU may take time. Can you share the latency for the first inference?

Thanks for your reply. I put the data and model to GPU before starting the timing, here are my codes based on EfficientSAM_example.py

for i in range(10):
    device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
    model = model.to(device)
    a = sample_image_tensor[None, ...]
    a = a.to(device)
    input_points = input_points.to(device)
    input_labels = input_labels.to(device)
    t1 = time.time()
    print('Running inference using ', model_name)
    predicted_logits, predicted_iou = model(
        a,
        input_points,
        input_labels,
    )
    t2 = time.time()
    print(f'timecost{t2-t1}')

and it shows:
Running inference using efficientsam_ti
timecost0.5455219745635986
Running inference using efficientsam_ti
timecost0.035993099212646484
Running inference using efficientsam_ti
timecost0.03607749938964844
Running inference using efficientsam_ti
timecost0.03591561317443848
Running inference using efficientsam_ti
timecost0.0360107421875
......

from efficientsam.

yformer avatar yformer commented on August 12, 2024

@liutongkun, can you move the model/data before the loop?

from efficientsam.

liutongkun avatar liutongkun commented on August 12, 2024

@liutongkun, can you move the model/data before the loop?

I modify the code to:

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = models['efficientsam_ti'].to(device)
a = sample_image_tensor[None, ...]
a = a.to(device)
input_points = input_points.to(device)
input_labels = input_labels.to(device)
for i in range(10):
    t1 = time.time()
    print('Running inference u sing ', 'efficientsam_ti')
    predicted_logits, predicted_iou = model(
        a,
        input_points,
        input_labels,
    )
    t2 = time.time()
    print(f'timecost{t2-t1}')

and it shows:
Running inference u sing efficientsam_ti
timecost0.56357741355896
Running inference u sing efficientsam_ti
timecost0.035813331604003906
Running inference u sing efficientsam_ti
timecost0.035944223403930664
Running inference u sing efficientsam_ti
timecost0.03553032875061035
Running inference u sing efficientsam_ti
timecost0.03602123260498047
......

from efficientsam.

EudicL avatar EudicL commented on August 12, 2024

@liutongkun, for the first inference, loading the model to GPU and moving the data to GPU may take time. Can you share the latency for the first inference?

Thanks for your reply. I put the data and model to GPU before starting the timing, here are my codes based on EfficientSAM_example.py

for i in range(10):
    device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
    model = model.to(device)
    a = sample_image_tensor[None, ...]
    a = a.to(device)
    input_points = input_points.to(device)
    input_labels = input_labels.to(device)
    t1 = time.time()
    print('Running inference using ', model_name)
    predicted_logits, predicted_iou = model(
        a,
        input_points,
        input_labels,
    )
    t2 = time.time()
    print(f'timecost{t2-t1}')

and it shows: Running inference using efficientsam_ti timecost0.5455219745635986 Running inference using efficientsam_ti timecost0.035993099212646484 Running inference using efficientsam_ti timecost0.03607749938964844 Running inference using efficientsam_ti timecost0.03591561317443848 Running inference using efficientsam_ti timecost0.0360107421875 ......

Thanks, it is useful

from efficientsam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.