kijai / ComfyUI-SUPIR

SUPIR upscaling wrapper for ComfyUI
Other
1.58k stars 87 forks source link

Latest ComfyUI Update broke Supir Node Compatability #144

Closed Vigilence closed 4 months ago

Vigilence commented 4 months ago

I just updated comfui to the latest update and none of my supir node workflows work. Uninstalling, reinstalling etc does not work.

kijai commented 4 months ago

I just tried with latest ComfyUI and I have no problems, what is the error you are getting?

dicksondickson commented 4 months ago

I'm getting this as well. Here is the log:

`Error occurred when executing SUPIR_conditioner:

The shape of the 2D attn_mask is torch.Size([77, 77]), but should be (1, 1).

File "C:\AI\ComfyUI\execution.py", line 151, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\AI\ComfyUI\execution.py", line 81, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\AI\ComfyUI\execution.py", line 74, in map_node_over_list results.append(getattr(obj, func)(slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\AI\ComfyUI\custom_nodes\ComfyUI-SUPIR\nodes_v2.py", line 637, in condition _c, _uc = SUPIR_model.conditioner.get_unconditional_conditioning(cond, uncond) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\AI\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\modules\encoders\modules.py", line 187, in get_unconditional_conditioning c = self(batch_c) ^^^^^^^^^^^^^ File "C:\Users\dickson\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nn\modules\module.py", line 1714, in _wrapped_call_impl return self._call_impl(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dickson\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nn\modules\module.py", line 1725, in _call_impl return forward_call(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\AI\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\modules\encoders\modules.py", line 208, in forward emb_out = embedder(batch[embedder.input_key]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dickson\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nn\modules\module.py", line 1714, in _wrapped_call_impl return self._call_impl(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dickson\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nn\modules\module.py", line 1725, in _call_impl return forward_call(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\AI\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\modules\encoders\modules.py", line 568, in forward z = self.encode_with_transformer(tokens.to(self.device)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\AI\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\modules\encoders\modules.py", line 580, in encode_with_transformer x = self.text_transformer_forward(x, attn_mask=self.model.attn_mask) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\AI\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\modules\encoders\modules.py", line 612, in text_transformer_forward x = r(x, attn_mask=attn_mask) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dickson\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nn\modules\module.py", line 1714, in _wrapped_call_impl return self._call_impl(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dickson\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nn\modules\module.py", line 1725, in _call_impl return forward_call(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dickson\AppData\Local\Programs\Python\Python311\Lib\site-packages\open_clip\transformer.py", line 263, in forward x = q_x + self.ls_1(self.attention(q_x=self.ln_1(q_x), k_x=k_x, v_x=v_x, attn_mask=attn_mask)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dickson\AppData\Local\Programs\Python\Python311\Lib\site-packages\open_clip\transformer.py", line 250, in attention return self.attn( ^^^^^^^^^^ File "C:\Users\dickson\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nn\modules\module.py", line 1714, in _wrapped_call_impl return self._call_impl(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dickson\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nn\modules\module.py", line 1725, in _call_impl return forward_call(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dickson\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nn\modules\activation.py", line 1368, in forward attn_output, attn_output_weights = F.multi_head_attention_forward( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dickson\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nn\functional.py", line 6100, in multi_head_attention_forward raise RuntimeError(`

dicksondickson commented 4 months ago

Is this relevant?

https://stackoverflow.com/questions/78108999/attention-mask-shape-error-shape-should-be-1-1

kijai commented 4 months ago

Okay I think I found it, some other custom node must have updated open-clip-torch as with it's latest version I'm getting same error. open-clip-torch==2.24.0 still works

dicksondickson commented 4 months ago

You are amazing. Thank you! I just installed open-clip-torch==2.24.0 like you said and its working again. The following is the nodes I have installed and it seems CCSR is the other node that have open-clip-torch in requirements.txt.

0.0 seconds: C:\AI\ComfyUI\custom_nodes\websocket_image_save.py 0.0 seconds: C:\AI\ComfyUI\custom_nodes\ComfyUI-Chibi-Nodes 0.0 seconds: C:\AI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale 0.0 seconds: C:\AI\ComfyUI\custom_nodes\rgthree-comfy 0.0 seconds: C:\AI\ComfyUI\custom_nodes\ComfyUI-Dickson-Nodes 0.0 seconds: C:\AI\ComfyUI\custom_nodes\ComfyUI-KJNodes 0.0 seconds: C:\AI\ComfyUI\custom_nodes\ComfyUI_essentials 0.0 seconds: C:\AI\ComfyUI\custom_nodes\ComfyUI_Comfyroll_CustomNodes 0.0 seconds: C:\AI\ComfyUI\custom_nodes\comfyui-prompt-reader-node 0.1 seconds: C:\AI\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts 0.1 seconds: C:\AI\ComfyUI\custom_nodes\ComfyUI-Impact-Pack 0.2 seconds: C:\AI\ComfyUI\custom_nodes\ComfyUI-Manager 0.4 seconds: C:\AI\ComfyUI\custom_nodes\ComfyUI-SUPIR 0.8 seconds: C:\AI\ComfyUI\custom_nodes\was-node-suite-comfyui 1.0 seconds: C:\AI\ComfyUI\custom_nodes\ComfyUI-CCSR 2.5 seconds: C:\AI\ComfyUI\custom_nodes\ComfyUI-Crystools

kijai commented 4 months ago

I found what caused it in the open-clip-torch update, and added a work around. Should now work even with the latest version.

sdk401 commented 4 months ago

Not working for me, not even importing, tried reinstalling, open-clip-torch is 2.24.0

1.2 seconds (IMPORT FAILED): C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR

kijai commented 4 months ago

Not working for me, not even importing, tried reinstalling, open-clip-torch is 2.24.0

1.2 seconds (IMPORT FAILED): C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR

Different error then, and that doesn't tell me anything, the real error is in the log somewhere.

sdk401 commented 4 months ago

Not working for me, not even importing, tried reinstalling, open-clip-torch is 2.24.0 1.2 seconds (IMPORT FAILED): C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR

Different error then, and that doesn't tell me anything, the real error is in the log somewhere.

here is the complete error, looks like something with flash-attn-cuda. worked fine yesterday

Traceback (most recent call last): File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\nodes.py", line 1907, in load_custom_node module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR__init.py", line 1, in from .nodes import SUPIR_Upscale File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR\nodes.py", line 11, in from .sgm.util import instantiate_from_config File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm__init.py", line 1, in from .models import AutoencodingEngine, DiffusionEngine File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\models__init.py", line 1, in from .autoencoder import AutoencodingEngine File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\models\autoencoder.py", line 12, in from ..modules.diffusionmodules.model import Decoder, Encoder File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\modules__init.py", line 1, in from .encoders.modules import GeneralConditioner File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\modules\encoders\modules.py", line 5, in import kornia File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia__init.py", line 8, in from . import ( File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\augmentation__init__.py", line 3, in from kornia.augmentation._2d import ( File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\augmentation_2d\init__.py", line 2, in from kornia.augmentation._2d.intensity import * File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\augmentation_2d\intensity\init__.py", line 29, in from kornia.augmentation._2d.intensity.plasma import RandomPlasmaBrightness, RandomPlasmaContrast, RandomPlasmaShadow File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\augmentation_2d\intensity\plasma.py", line 5, in from kornia.contrib import diamond_square File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\contrib\init__.py", line 15, in from .image_stitching import ImageStitcher File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\contrib\image_stitching.py", line 7, in from kornia.feature import LocalFeatureMatcher, LoFTR File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\feature\init__.py", line 7, in from .integrated import ( File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\feature\integrated.py", line 17, in from .lightglue import LightGlue File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\feature\lightglue.py", line 30, in from flash_attn.modules.mha import FlashCrossAttention File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\flash_attn\init__.py", line 3, in from flash_attn.flash_attn_interface import ( File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\flash_attn\flash_attn_interface.py", line 10, in import flash_attn_2_cuda as flash_attn_cuda ImportError: DLL load failed while importing flash_attn_2_cuda: The specified procedure could not be found.

Cannot import C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR module for custom nodes: DLL load failed while importing flash_attn_2_cuda: The specified procedure could not be found.

dicksondickson commented 4 months ago

@sdk401 Are you missing flash attention? Installing flash attention using their recompiled wheels via pip never worked for me on windows. Other's have reported the same: https://github.com/Dao-AILab/flash-attention/issues/595

The only way I had it working was to compile my own. I have compile scripts here: https://github.com/dicksondickson/ComfyUI-Clean-Install

sdk401 commented 4 months ago

@sdk401 Are you missing flash attention?

Only if updating comfyui broke it. I installed it before for Lumina wrapper and it worked fine. Will try again.

dicksondickson commented 4 months ago

@sdk401 Are you missing flash attention?

Only if updating comfyui broke it. I installed it before for Lumina wrapper and it worked fine. Will try again.

As far as I know, ComfyUI doesn't install Flash Attention or updates Flash Attention. Comfy uses Flash Attention but doesn't require it. Although I could be wrong and my knowledge is outdated.

kijai commented 4 months ago

Not working for me, not even importing, tried reinstalling, open-clip-torch is 2.24.0 1.2 seconds (IMPORT FAILED): C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR

Different error then, and that doesn't tell me anything, the real error is in the log somewhere.

here is the complete error, looks like something with flash-attn-cuda. worked fine yesterday

Traceback (most recent call last): File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\nodes.py", line 1907, in load_custom_node module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIRinit.py", line 1, in from .nodes import SUPIR_Upscale File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR\nodes.py", line 11, in from .sgm.util import instantiate_from_config File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgminit.py", line 1, in from .models import AutoencodingEngine, DiffusionEngine File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\modelsinit.py", line 1, in from .autoencoder import AutoencodingEngine File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\models\autoencoder.py", line 12, in from ..modules.diffusionmodules.model import Decoder, Encoder File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\modulesinit.py", line 1, in from .encoders.modules import GeneralConditioner File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\modules\encoders\modules.py", line 5, in import kornia File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\korniainit.py", line 8, in from . import ( File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\augmentationinit.py", line 3, in from kornia.augmentation._2d import ( File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\augmentation_2dinit.py", line 2, in from kornia.augmentation._2d.intensity import * File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\augmentation_2d\intensityinit.py", line 29, in from kornia.augmentation._2d.intensity.plasma import RandomPlasmaBrightness, RandomPlasmaContrast, RandomPlasmaShadow File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\augmentation_2d\intensity\plasma.py", line 5, in from kornia.contrib import diamond_square File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\contribinit.py", line 15, in from .image_stitching import ImageStitcher File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\contrib\image_stitching.py", line 7, in from kornia.feature import LocalFeatureMatcher, LoFTR File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\featureinit.py", line 7, in from .integrated import ( File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\feature\integrated.py", line 17, in from .lightglue import LightGlue File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\kornia\feature\lightglue.py", line 30, in from flash_attn.modules.mha import FlashCrossAttention File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\flash_attninit.py", line 3, in from flash_attn.flash_attn_interface import ( File "C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\flash_attn\flash_attn_interface.py", line 10, in import flash_attn_2_cuda as flash_attn_cuda ImportError: DLL load failed while importing flash_attn_2_cuda: The specified procedure could not be found.

Cannot import C:_sd-win\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-SUPIR module for custom nodes: DLL load failed while importing flash_attn_2_cuda: The specified procedure could not be found.

I don't really know what's causing this, but as it seems to be related to kornia, I took a closer look at where it's used...... and realized it's not necessary. So I've removed it's import totally, if it doesn't clear the error, at very least the error should change now if you update and run.

sdk401 commented 4 months ago

I don't really know what's causing this, but as it seems to be related to kornia, I took a closer look at where it's used...... and realized it's not necessary. So I've removed it's import totally, if it doesn't clear the error, at very least the error should change now if you update and run.

Updated, error gone, nodes load, thanks!

Vigilence commented 4 months ago

Update fixed the issue. Thanks!