# Flux Diffusers Pipeline's unusual runtime in Google colab

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflux-diffusers-pipelines-unusual-runtime-in-google-colab%2F108978%3E%5C
**Category:** Models\
**Created:** [September 27, 2024, 8:27am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflux-diffusers-pipelines-unusual-runtime-in-google-colab%2F108978 "2024-09-27T08:27:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gencause](https://avatars.discourse-cdn.com/v4/letter/g/5e9695/32.png) [@Gencause](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FGencause)%5C
**Post date:** [September 27, 2024, 8:27am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflux-diffusers-pipelines-unusual-runtime-in-google-colab%2F108978%2F1 "2024-09-27T08:27:28Z")

</div>

Hi,

I tried to to run the guided distilled diffusion pipeline of flux as given in [Flux](https://huggingface.co/docs/diffusers/main/en/api/pipelines/flux)

It seems the following part is taking forever to run in Google colab.

prompt = “a tiny astronaut hatching from an egg on the moon”

out = pipe(  
prompt=prompt,  
guidance\_scale=3.5,  
height=768,  
width=1360,  
num\_inference\_steps=50,  
).images[0]  
out.save(“image.png”)

Kindly advise.

Thanks.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 27, 2024, 8:38am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflux-diffusers-pipelines-unusual-runtime-in-google-colab%2F108978%2F2 "2024-09-27T08:38:04Z")

</div>

Google Colab does not seem to be very welcoming of its use in image generation, so there could be various causes, but so far it seems that Flux generation is usually possible, so it is probably not a restriction or something.

Assuming you are using the Flux dev version, the only problems with running the free version of Colab are width and num\_inference\_steps. Try reducing these.

If it is definitively wrong, you will get an error, but if the computer decides that it might be able to run it over time, it will happen forever that way.  
Also, if there is insufficient RAM, VRAM, or disk space, it may stop without an error, and the action in this case is similar.

---

<div class="post-metadata">

**Author:** ![Gencause](https://avatars.discourse-cdn.com/v4/letter/g/5e9695/32.png) [@Gencause](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FGencause)%5C
**Post date:** [September 27, 2024, 8:52am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflux-diffusers-pipelines-unusual-runtime-in-google-colab%2F108978%2F3 "2024-09-27T08:52:49Z")

</div>

Thanks for the advise.  
I’m using num\_steps =10 and img dims 1024 x 1024.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 27, 2024, 10:44am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflux-diffusers-pipelines-unusual-runtime-in-google-colab%2F108978%2F4 "2024-09-27T10:44:10Z")

</div>

Could it be the free version of Colab?  
If so, with 16GB of VRAM, it will take endless hours to generate, I don’t even know if it will take an hour.

I’m sorry for the Japanese page, but you can try it with quantized flux as shown in the following page.  
I think there is an English version of the know-how if you search for it.

> **[FLUX.1をdiffusers環境下VRAM 16GB以下のGPUで使用する - Qiita](https://qiita.com/yamichi77/items/1f12bac65d1584900b35)**
>
> 概要つい最近Stable Diffusion開発者の方達が発表したFLUX.1ですが、容量が大きく大体のPCではVRAM不足で動きません。色々調査を行った所、量子化を行うことで動作することが判明…

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [September 27, 2024, 4:36pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflux-diffusers-pipelines-unusual-runtime-in-google-colab%2F108978%2F5 "2024-09-27T16:36:40Z")

</div>

Hi,

The reason is because by default it runs on CPU. Try adding `pipe.to("cuda")` before running it.

---

<div class="post-metadata">

**Author:** ![Gencause](https://avatars.discourse-cdn.com/v4/letter/g/5e9695/32.png) [@Gencause](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FGencause)%5C
**Post date:** [September 27, 2024, 10:38pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflux-diffusers-pipelines-unusual-runtime-in-google-colab%2F108978%2F6 "2024-09-27T22:38:22Z")

</div>

Hi,

Thanks a lot for the suggestions. Actually, as it turns out Colab does not always offer GPU support as it does for CPU support. It should work when and if it does. I was wondering if we could make any fundamental changes in the class _FlowMatchEulerDiscreteSchedulerOutput_ of the function _scheduling\_flow\_match\_euler\_discrete._

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 28, 2024, 12:22am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflux-diffusers-pipelines-unusual-runtime-in-google-colab%2F108978%2F7 "2024-09-28T00:22:27Z")

</div>

Is this a strategy to dynamically switch the use of CUDA?

The scheduler is not a regular iterator or anything like that, it’s in charge of the noise removal schedule, so unless you know a lot about it, messing with it will ruin the image. Strictly speaking, it is somewhat different, but in WebUI and ComfyUI, it is a sampler.

Maybe, better yet, determine if you can use CUDA just before inference, and if not, give up.  
You should be able to determine that with torch.cuda.available().

It is not realistic to infer a Flux model using only CPU, at least for now, let alone an SD 1.5 model.

It is possible to at least offload some tensors to RAM when VRAM is insufficient, but it is enough to use pipe.enable\_cpu\_offloading() for that.

---

<div class="post-metadata">

**Author:** ![Gencause](https://avatars.discourse-cdn.com/v4/letter/g/5e9695/32.png) [@Gencause](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FGencause)%5C
**Post date:** [September 28, 2024, 2:59am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflux-diffusers-pipelines-unusual-runtime-in-google-colab%2F108978%2F8 "2024-09-28T02:59:43Z")

</div>

No. It has something to do with the step of the number of steps taken by the model during inference/sampling.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 28, 2024, 3:49am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflux-diffusers-pipelines-unusual-runtime-in-google-colab%2F108978%2F9 "2024-09-28T03:49:24Z")

</div>

So you want to speed up the inference itself? Then wouldn’t it be easier to use Hyper Flux or some other such thing? The page below says SD, but you can also find SDXL and Flux’s LoRA there.

> **[ByteDance/Hyper-SD · Hugging Face](https://huggingface.co/ByteDance/Hyper-SD)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

Also, there are a couple of techniques recently proposed in HF that may not be as easy to use as Hyper.

> **[FLUX Realtime - a Hugging Face Space by KingNish](https://huggingface.co/spaces/KingNish/Realtime-FLUX)**
>
> High quality Images in Realtime

> **[madebyollin/taef1 · Hugging Face](https://huggingface.co/madebyollin/taef1)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![ankitom](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@ankitom](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fankitom)%5C
**Post date:** [January 29, 2025, 11:27am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fflux-diffusers-pipelines-unusual-runtime-in-google-colab%2F108978%2F10 "2025-01-29T11:27:34Z")

</div>

Thanks for this wonderful tip. It saves a lot of time.
