Skip to content

Model loading is slow / Time before generating #968

@Feniksss

Description

@Feniksss

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

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions