xhinker / sd_embed

Generate long weighted prompt embeddings for Stable Diffusion
Apache License 2.0
60 stars 6 forks source link

No support for CPU #16

Closed davidrippel closed 2 weeks ago

davidrippel commented 2 weeks ago

Hi,

I am trying to run on CPU only (no GPU) with this code: prompt_embeds, pooled_prompt_embeds = get_weighted_text_embeddings_flux1( pipe = pipe, prompt = prompt, device = "cpu" )

And getting this error: Traceback (most recent call last): File "/home/david_rippel/flux/test1.py", line 89, in prompt_embeds, pooled_prompt_embeds = get_weighted_text_embeddings_flux1( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/david_rippel/flux/env/lib/python3.11/site-packages/sd_embed/embedding_funcs.py", line 1366, in get_weighted_text_embeddings_flux1 pipe.text_encoder.to(target_device) File "/home/david_rippel/flux/env/lib/python3.11/site-packages/transformers/modeling_utils.py", line 2905, in to return super().to(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/david_rippel/flux/env/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1174, in to return self._apply(convert) ^^^^^^^^^^^^^^^^^^^^ File "/home/david_rippel/flux/env/lib/python3.11/site-packages/torch/nn/modules/module.py", line 780, in _apply module._apply(fn) File "/home/david_rippel/flux/env/lib/python3.11/site-packages/torch/nn/modules/module.py", line 780, in _apply module._apply(fn) File "/home/david_rippel/flux/env/lib/python3.11/site-packages/torch/nn/modules/module.py", line 780, in _apply module._apply(fn) File "/home/david_rippel/flux/env/lib/python3.11/site-packages/torch/nn/modules/module.py", line 805, in _apply param_applied = fn(param) ^^^^^^^^^ File "/home/david_rippel/flux/env/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1160, in convert return t.to( ^^^^^ File "/home/david_rippel/flux/env/lib/python3.11/site-packages/torch/cuda/init.py", line 314, in _lazy_init torch._C._cuda_init() RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx

xhinker commented 2 weeks ago

CLIP and T5 need a GPU device to generate the text embedding, you can input "cuda:0", "cuda:1" etc , but not CPU

xhinker commented 2 weeks ago

If your pipe is in CPU, sd_embed will release the VRAM usage after embedding

davidrippel commented 2 weeks ago

So I cannot use it without a GPU?

xhinker commented 2 weeks ago

As the error you see, it it the HuggingFace Transformer package can't generate the embedding using a CPU, yes, you cannot use it without a GPU