question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Model loading is slow / Time before generating

See original GitHub issue

Describe the bug

I have used a simple realization on T4 (Google Cloud)

import torch
from torch import autocast
from diffusers import StableDiffusionPipeline

access_token = ""

pipe = StableDiffusionPipeline.from_pretrained(
    "CompVis/stable-diffusion-v1-4",
    revision="fp16",
    torch_dtype=torch.float16,
    use_auth_token=access_token,
)
pipe = pipe.to("cuda")

prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt).images[0]

image.save("astronaut_rides_horse_1.png")

And generating can take 10-15 sec per image - it’s good result. But we have a problem with time before start of generating. Pre-loading models and files can take ~ 30 sec. For example: 20221024-penj-42kb

How we can speed up the preloading?

Reproduction

No response

Logs

No response

System Info

Google Cloud - T4

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
piEspositocommented, Oct 27, 2022

@patrickvonplaten nice! This was a sife effect I didn’t think of when I was implementing it.

0reactions
Fenikssscommented, Oct 26, 2022

In my tests, the time goes down from 22 seconds to 3 seconds. Will open a PR to improve the docs here.

hm… thank you! It improved the time. A delay stay about 10-11 sec now. + 11 sec per image generating. 2022-10-26_16-19

Read more comments on GitHub >

github_iconTop Results From Across the Web

[model_utils] very slow model instantiation #9205 - GitHub
For some reason I'm noticing a very slow model instantiation time. For example to load shleifer/distill-mbart-en-ro-12-4 it takes.
Read more >
Extremely slow model load with keras - python - Stack Overflow
When I try to load them, using load_model , the time required for each model is quite large and incremental. The loading is...
Read more >
OpenGL ES model loader is slow?
The fastest model loading basically happens when you can memory-map a binary file and pass the resulting pointer, with unmodified/un-parsed data ...
Read more >
Handling big models - Hugging Face
Load those weights inside the model. While this works very well for regularly sized models, this workflow has some clear limitations when we...
Read more >
Investigating Slow View Load Requests - Tableau Help
The Slow View Load Requests chart shows when views are rendering more slowly than normal on Tableau Server. To do this, the chart...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found