TheLastBen / fast-stable-diffusion

fast-stable-diffusion + DreamBooth
MIT License
7.49k stars 1.31k forks source link

Google Collab Pro: WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions #2615

Closed HaikenEdge closed 5 months ago

HaikenEdge commented 11 months ago

When running Start Stable-Diffusion module:

WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for: PyTorch 2.0.1+cu118 with CUDA 1108 (you have 2.1.0+cu118) Python 3.10.11 (you have 3.10.12) Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers) Memory-efficient attention, SwiGLU, sparse and more won't be available. Set XFORMERS_MORE_DETAILS=1 for more details

After model loads and attempting a new task:

Error completing request Arguments: ('task(z56ngcsuo73sy3x)', '(Color photograph) of (very beautiful) woman, elean0r_n0texist, wearing (bodycon little black dress)1.1, at a (movie premiere red carpet). candid, (full color), face detail, intricate high detail, dramatic, skin pores, cinematic lighting, detailed, (vibrant, photo realistic, dramatic, sharp focus) ((film grain, skin details, high detailed skin texture, 8k hdr, dslr))', '', ['Schizo Negative'], 30, 'Euler a', 1, 1, 7, 768, 512, False, 0.7, 2, 'Latent', 0, 0, 0, 'Use same checkpoint', 'Use same sampler', '', '', [], <gradio.routes.Request object at 0x7d29ac5d7eb0>, 0, False, '', 0.8, -1, False, -1, 0, 0, 0, False, False, 'positive', 'comma', 0, False, False, '', 1, '', [], 0, '', [], 0, '', [], True, False, False, False, 0, False) {} Traceback (most recent call last): File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/call_queue.py", line 57, in f res = list(func(*args, kwargs)) File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/call_queue.py", line 36, in f res = func(*args, kwargs) File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/txt2img.py", line 55, in txt2img processed = processing.process_images(p) File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/processing.py", line 732, in process_images res = process_images_inner(p) File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/processing.py", line 867, in process_images_inner samples_ddim = p.sample(conditioning=p.c, unconditional_conditioning=p.uc, seeds=p.seeds, subseeds=p.subseeds, subseed_strength=p.subseed_strength, prompts=p.prompts) File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/processing.py", line 1140, in sample samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning, image_conditioning=self.txt2img_image_conditioning(x)) File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/sd_samplers_kdiffusion.py", line 235, in sample samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args=self.sampler_extra_args, disable=False, callback=self.callback_state, extra_params_kwargs)) File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/sd_samplers_common.py", line 261, in launch_sampling return func() File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/sd_samplers_kdiffusion.py", line 235, in samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args=self.sampler_extra_args, disable=False, callback=self.callback_state, *extra_params_kwargs)) File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(args, kwargs) File "/content/gdrive/MyDrive/sd/stablediffusion/src/k-diffusion/k_diffusion/sampling.py", line 145, in sample_euler_ancestral denoised = model(x, sigmas[i] * s_in, extra_args) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/sd_samplers_cfg_denoiser.py", line 188, in forward x_out[a:b] = self.inner_model(x_in[a:b], sigma_in[a:b], cond=make_condition_dict(c_crossattn, image_cond_in[a:b])) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, *kwargs) File "/content/gdrive/MyDrive/sd/stablediffusion/src/k-diffusion/k_diffusion/external.py", line 112, in forward eps = self.get_eps(input c_in, self.sigma_to_t(sigma), kwargs) File "/content/gdrive/MyDrive/sd/stablediffusion/src/k-diffusion/k_diffusion/external.py", line 138, in get_eps return self.inner_model.apply_model(*args, kwargs) File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/sd_hijack_utils.py", line 17, in setattr(resolved_obj, func_path[-1], lambda *args, *kwargs: self(args, kwargs)) File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/sd_hijack_utils.py", line 26, in call return self.sub_func(self.__orig_func, *args, kwargs) File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/sd_hijack_unet.py", line 48, in apply_model return orig_func(self, x_noisy.to(devices.dtype_unet), t.to(devices.dtype_unet), cond, kwargs).float() File "/content/gdrive/MyDrive/sd/stablediffusion/ldm/models/diffusion/ddpm.py", line 858, in apply_model x_recon = self.model(x_noisy, t, cond) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "/content/gdrive/MyDrive/sd/stablediffusion/ldm/models/diffusion/ddpm.py", line 1329, in forward out = self.diffusion_model(x, t, context=cc) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, *kwargs) File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/sd_unet.py", line 91, in UNetModel_forward return ldm.modules.diffusionmodules.openaimodel.copy_of_UNetModel_forward_for_webui(self, x, timesteps, context, args, kwargs) File "/content/gdrive/MyDrive/sd/stablediffusion/ldm/modules/diffusionmodules/openaimodel.py", line 776, in forward h = module(h, emb, context) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, *kwargs) File "/content/gdrive/MyDrive/sd/stablediffusion/ldm/modules/diffusionmodules/openaimodel.py", line 84, in forward x = layer(x, context) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(args, kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, kwargs) File "/content/gdrive/MyDrive/sd/stablediffusion/ldm/modules/attention.py", line 334, in forward x = block(x, context=context[i]) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "/content/gdrive/MyDrive/sd/stablediffusion/ldm/modules/attention.py", line 269, in forward return checkpoint(self._forward, (x, context), self.parameters(), self.checkpoint) File "/content/gdrive/MyDrive/sd/stablediffusion/ldm/modules/diffusionmodules/util.py", line 114, in checkpoint return CheckpointFunction.apply(func, len(inputs), args) File "/usr/local/lib/python3.10/dist-packages/torch/autograd/function.py", line 539, in apply return super().apply(args, kwargs) # type: ignore[misc] File "/content/gdrive/MyDrive/sd/stablediffusion/ldm/modules/diffusionmodules/util.py", line 129, in forward output_tensors = ctx.run_function(ctx.input_tensors) File "/content/gdrive/MyDrive/sd/stablediffusion/ldm/modules/attention.py", line 272, in _forward x = self.attn1(self.norm1(x), context=context if self.disable_self_attn else None) + x File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(args, kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, **kwargs) File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/sd_hijack_optimizations.py", line 496, in xformers_attention_forward out = xformers.ops.memory_efficient_attention(q, k, v, attn_bias=None, op=get_xformers_flash_attention_op(q, k, v)) File "/usr/local/lib/python3.10/dist-packages/xformers/ops/fmha/init.py", line 192, in memory_efficient_attention return _memory_efficient_attention( File "/usr/local/lib/python3.10/dist-packages/xformers/ops/fmha/init.py", line 290, in _memory_efficient_attention return _memory_efficient_attention_forward( File "/usr/local/lib/python3.10/dist-packages/xformers/ops/fmha/init__.py", line 306, in _memory_efficient_attention_forward op = _dispatch_fw(inp) File "/usr/local/lib/python3.10/dist-packages/xformers/ops/fmha/dispatch.py", line 94, in _dispatch_fw return _run_priority_list( File "/usr/local/lib/python3.10/dist-packages/xformers/ops/fmha/dispatch.py", line 69, in _run_priority_list raise NotImplementedError(msg) NotImplementedError: No operator found for memory_efficient_attention_forward with inputs: query : shape=(1, 6144, 8, 40) (torch.float16) key : shape=(1, 6144, 8, 40) (torch.float16) value : shape=(1, 6144, 8, 40) (torch.float16) attn_bias : <class 'NoneType'> p : 0.0 flshattF is not supported because: xFormers wasn't build with CUDA support Operator wasn't built - see python -m xformers.info for more info tritonflashattF is not supported because: xFormers wasn't build with CUDA support Operator wasn't built - see python -m xformers.info for more info triton is not available requires A100 GPU cutlassF is not supported because: xFormers wasn't build with CUDA support Operator wasn't built - see python -m xformers.info for more info smallkF is not supported because: xFormers wasn't build with CUDA support dtype=torch.float16 (supported: {torch.float32}) max(query.shape[-1] != value.shape[-1]) > 32 Operator wasn't built - see python -m xformers.info for more info unsupported embed per head: 40


Ptentacle1 commented 11 months ago

Commenting to say I'm getting this error too. Was generating fine, stopped for an hour, booted it back up and now I'm getting this xformers error. Colab Pro user.

kilimchoi commented 11 months ago

Same. something is broken. I've tried installing xformers==0.0.20 but so many other packages fail to install.

Mortilis commented 11 months ago

Here's the key part:

WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for: PyTorch 2.0.1+cu118 with CUDA 1108 (you have 2.1.0+cu118) Python 3.10.11 (you have 3.10.12)

There's an incompatibility with Python/PyTorch and xFormers. Perhaps someone can give us a temporary fix, If not, we'll just have to wait. I suspect everyone is getting this exact error.

scrrd4lyf commented 11 months ago

Seeing this same message as well.

kuvuuuuu commented 11 months ago

same here.

zxdc8 commented 11 months ago

Just had the same problem, working fine an hour ago now broken!

zakpurp commented 11 months ago

Same here!

stableleon commented 11 months ago

Same here!

paradoxtown commented 11 months ago

Try this at the beginning of the file.

!pip install lmdb
!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 torchtext==0.15.2+cpu torchdata==0.6.1 --index-url https://download.pytorch.org/whl/cu118

image

arvinmark05 commented 11 months ago

Try this at the beginning of the file.

!pip install lmdb
!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 torchtext==0.15.2+cpu torchdata==0.6.1 --index-url https://download.pytorch.org/whl/cu118

image

thanks bro it works for me!

Ptentacle1 commented 11 months ago

Try this at the beginning of the file.

!pip install lmdb
!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 torchtext==0.15.2+cpu torchdata==0.6.1 --index-url https://download.pytorch.org/whl/cu118

image

Worked for me as well! Thanks!

scrrd4lyf commented 11 months ago

Try this at the beginning of the file.

!pip install lmdb
!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 torchtext==0.15.2+cpu torchdata==0.6.1 --index-url https://download.pytorch.org/whl/cu118

image

worked for me as well

Azura-13 commented 11 months ago

Same Issue

However scrrd4lyf ^^ fix seems to be working well

scrrd4lyf commented 11 months ago

Same Issue

However scrrd4lyf ^^ fix seems to be working well

oh nah man, this is all paradoxtown

williamsblood commented 11 months ago

Ty worked here!

HaikenEdge commented 11 months ago

Try this at the beginning of the file.

!pip install lmdb
!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 torchtext==0.15.2+cpu torchdata==0.6.1 --index-url https://download.pytorch.org/whl/cu118

image

Yep, this works. Thanks man!

zxdc8 commented 11 months ago

paradoxtown commented Oct 19, 2023

worked for me!

kilimchoi commented 11 months ago

is anyone now getting TypeError: check_deprecated_parameters() missing 1 required keyword-only argument: 'kwargs' when trying to test the trained model?

djwashout commented 11 months ago

works for me too. thanks!

chevyriet commented 11 months ago

Try this at the beginning of the file.

!pip install lmdb
!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 torchtext==0.15.2+cpu torchdata==0.6.1 --index-url https://download.pytorch.org/whl/cu118

image

worked for me, thanks. quick question, is this safe to run before running the rest of the notebook? or is it advised to run this after all requirements have already been installed/updated? @paradoxtown

James11082 commented 11 months ago

Try this at the beginning of the file.

!pip install lmdb
!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 torchtext==0.15.2+cpu torchdata==0.6.1 --index-url https://download.pytorch.org/whl/cu118

image

Many thanks! I bow to your infinite wisdom 🙏

iaclaudioia8 commented 11 months ago

One question, now have I always to install this? or with just one time enough?

paradoxtown commented 11 months ago

Try this at the beginning of the file.

!pip install lmdb
!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 torchtext==0.15.2+cpu torchdata==0.6.1 --index-url https://download.pytorch.org/whl/cu118

image

worked for me, thanks. quick question, is this safe to run before running the rest of the notebook? or is it advised to run this after all requirements have already been installed/updated? @paradoxtown

Yes, it is safe since it just installs some libraries with compatible versions and there is no conflict. Theoretically, you are correct. It would be better to run it after installing all other requirements to cover these incompatible version. But it didn't work.

paradoxtown commented 11 months ago

One question, now have I always to install this? or with just one time enough?

If you are using colab, you have to install this everytime. If you are running sd in your local env, no.

iaclaudioia8 commented 11 months ago

One question, now have I always to install this? or with just one time enough?

If you are using colab, you have to install this everytime. If you are running sd in your local env, no.

ufff it take more time to execute :( i mean google colab is not free and spent CPU...

drnehneh commented 11 months ago

Try this at the beginning of the file.

!pip install lmdb
!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 torchtext==0.15.2+cpu torchdata==0.6.1 --index-url https://download.pytorch.org/whl/cu118

image

Not working for me, this error apears

ARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for: PyTorch 2.1.0+cu121 with CUDA 1201 (you have 2.1.0+cu118) Python 3.10.13 (you have 3.10.12)

Maximb1985 commented 11 months ago

doesn't work unfortunately, same error

martindubo commented 11 months ago

Same error, 1111 does not work

Maximb1985 commented 11 months ago

Guys, has anyone been able to solve the problem?

drnehneh commented 11 months ago

Guys, has anyone been able to solve the problem?

Nope 😞

Marsh-6 commented 11 months ago

Try this at the beginning of the file.

!pip install lmdb
!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 torchtext==0.15.2+cpu torchdata==0.6.1 --index-url https://download.pytorch.org/whl/cu118

image

This solution worked yesterday but stopped working today :(

TheLastBen commented 11 months ago

use the latest notebook

Mortilis commented 11 months ago

use the latest notebook

I still get this error.

WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for: PyTorch 2.1.0+cu121 with CUDA 1201 (you have 2.1.0+cu118) Python 3.10.13 (you have 3.10.12) Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers) Memory-efficient attention, SwiGLU, sparse and more won't be available. Set XFORMERS_MORE_DETAILS=1 for more details

Marsh-6 commented 11 months ago

use the latest notebook

I'm also still getting the error unfortunately

TheLastBen commented 11 months ago

try again

bladewolf74 commented 11 months ago

use the latest notebook

I still get this error.

WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for: PyTorch 2.1.0+cu121 with CUDA 1201 (you have 2.1.0+cu118) Python 3.10.13 (you have 3.10.12) Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers) Memory-efficient attention, SwiGLU, sparse and more won't be available. Set XFORMERS_MORE_DETAILS=1 for more details

According to the WARNING, update the install version that add at the beginning of the file.

!pip install lmdb
!pip install torch==2.1.0+cu121 torchvision==0.16.0+cu121 torchaudio==2.1.0 torchtext==0.16.0+cpu torchdata==0.7.0 --index-url https://download.pytorch.org/whl/cu121

image I was got the WARNING too, but now I'm using normally, by try to update that. image

Marsh-6 commented 11 months ago

try again

Worked now. Thanks so much :)

I do get "no module 'xformers'. Processing without..." but the thing still launches and I seem to be able to generate images as always.

Thanks again Ben!

HaikenEdge commented 11 months ago

try again

try again

Worked now. Thanks so much :)

I do get "no module 'xformers'. Processing without..." but the thing still launches and I seem to be able to generate images as always.

Thanks again Ben!

Also got the "no module 'xformers'. Processing without..." message, but can also generate images.

TheLastBen commented 11 months ago

Also got the "no module 'xformers'. Processing without..." message, but can also generate images.

replaced xformers with SDP, almost the same performance

Bluebang commented 11 months ago

Try this at the beginning of the file.

!pip install lmdb
!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 torchtext==0.15.2+cpu torchdata==0.6.1 --index-url https://download.pytorch.org/whl/cu118

image

My friend, you are the real hero.

williamsblood commented 11 months ago

Also got the "no module 'xformers'. Processing without..." message, but can also generate images.

replaced xformers with SDP, almost the same performance

But after this last adjustment, the capability of a T4 GPU with more RAM to generate an image and do Hires. fix no longer works here. The Colab GPU has 15GB of VRAM, and I can't generate an image of even 768x1344 with a HiRes of 1.5 anymore

ValdemarVel commented 11 months ago

Попробуйте сделать это в начале файла.

!pip install lmdb
!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 torchtext==0.15.2+cpu torchdata==0.6.1 --index-url https://download.pytorch.org/whl/cu118

образ

How to do it for Google Drive? To install it there?

djwashout commented 11 months ago

I did add the pip install commands but no im getting no module 'xformers'. Processing without... And it doesn't load... any progress on this?

TheLastBen commented 11 months ago

I'll try different fixes without increasing the notebook initialization time, but google is constantly trying to discourage the use of colab, so I recommend the alternative, Paperspace and Runpod.

kuvuuuuu commented 11 months ago

sdp is waay slowed my work

jcvijr commented 11 months ago

Try this at the beginning of the file.

!pip install lmdb
!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 torchtext==0.15.2+cpu torchdata==0.6.1 --index-url https://download.pytorch.org/whl/cu118

image

It worked for me, just run it in a cell before running A1111 first time.

pavluka6 commented 11 months ago

use the latest notebook

I still get this error. WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for: PyTorch 2.1.0+cu121 with CUDA 1201 (you have 2.1.0+cu118) Python 3.10.13 (you have 3.10.12) Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers) Memory-efficient attention, SwiGLU, sparse and more won't be available. Set XFORMERS_MORE_DETAILS=1 for more details

According to the WARNING, update the install version that add at the beginning of the file.

!pip install lmdb
!pip install torch==2.1.0+cu121 torchvision==0.16.0+cu121 torchaudio==2.1.0 torchtext==0.16.0+cpu torchdata==0.7.0 --index-url https://download.pytorch.org/whl/cu121

image I was got the WARNING too, but now I'm using normally, by try to update that. image

Thanks man, this worked for me!

TheLastBen commented 11 months ago

use the latest notebook, no need to run any additional code

djwashout commented 11 months ago

Seems fixed now! thx!

Sashimi-jp commented 11 months ago

use the latest notebook, no need to run any additional code

When I switch the runtime GPU in Google Colab to something other than T4 (like V100), I encounter an error upon generation. Have you experienced this issue?