# Why is the diffusers library slow?

**URL:** <https://discuss.huggingface.co/t/why-is-the-diffusers-library-slow/33884>\
**Category:** 🧨 Diffusers\
**Created:** [March 15, 2023, 7:16pm UTC](https://discuss.huggingface.co/t/why-is-the-diffusers-library-slow/33884 "2023-03-15T19:16:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadirnar](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/kadirnar/32/14743_2.png) [@kadirnar](https://discuss.huggingface.co/u/kadirnar)\
**Post date:** [March 15, 2023, 7:16pm UTC](https://discuss.huggingface.co/t/why-is-the-diffusers-library-slow/33884/1 "2023-03-15T19:16:25Z")

</div>

The AUTOMATIC1111 application works in 3-4 seconds, but only takes 15 seconds when I use diffusers.

Diffusers:

```auto
def stable_diffusion_text2img(
    model_path: str,
    prompt: str,
    negative_prompt: str,
    num_images_per_prompt: int,
    guidance_scale: int,
    num_inference_step: int,
    height: int,
    width: int,
):

    pipe = StableDiffusionPipeline.from_pretrained(
        model_path, safety_checker=None, torch_dtype=torch.float16
    ).to("cuda")

    pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
    pipe.enable_xformers_memory_efficient_attention()

    images = pipe(
        prompt,
        height=height,
        width=width,
        negative_prompt=negative_prompt,
        num_images_per_prompt=num_images_per_prompt,
        num_inference_steps=num_inference_step,
        guidance_scale=guidance_scale,
    ).images

    return images

```

How can I speed up the code?
