balazik / ComfyUI-PuLID-Flux

PuLID-Flux ComfyUI implementation
Apache License 2.0
395 stars 28 forks source link

RuntimeError: expected scalar type Half but found BFloat16 when executing SamplerCustomAdvanced node #6

Closed wip163 closed 1 month ago

wip163 commented 1 month ago

ComfyUI_windows\python_embeded\Lib\site-packages\torch\nn\functional.py", line 2573, in layer_norm return torch.layer_norm(input, normalized_shape, weight, bias, eps, torch.backends.cudnn.enabled) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: expected scalar type Half but found BFloat16

balazik commented 1 month ago

Hi.

  1. which FLUX.1-dev model did you use ? I mean the dtype (like F8_e4m3fn or F8_e5m2, checkpoint with backed F8 model etc.) If you don't know just paste here the link where you downloaded it.
  2. I need to know the HW (exect graphic card name) that you using (if cloud, then what type of pod you use).
balazik commented 1 month ago

Try to pull the new version (of ComfyUI-PuLID-Flux). It should check for bfloat16 support and set the dtype to float16 if not supported. And let me know if it helped.

patientx commented 1 month ago

RuntimeError: expected scalar type Half but found BFloat16

this is after the update, I am using weight type fp8_e4m3fn, with fp8 t5 and normal clip. I am also using a rx 6600 with zluda on windows.

balazik commented 1 month ago

@patientx sorry, not waiting for you to confirm. Ok, changed the code so it detects what dtype will the original unet model use (manual cast) so If the model can run on the system also the pulid should. It should detect your special case running on ZLUDA.

Let me know if it helped. (here: so I can better understand the needs for all platforms).

wip163 commented 1 month ago

I updated to your new version's nodes and it works now, thank you!

patientx commented 1 month ago

@patientx sorry, not waiting for you to confirm. Ok, changed the code so it detects what dtype will the original unet model use (manual cast) so If the model can run on the system also the pulid should. It should detect your special case running on ZLUDA.

Let me know if it helped. (here: so I can better understand the needs for all platforms).

No problem, I can also confirm it now works with the latest version with amd + zluda combo. (mentioned it again because sometimes this causes specific problems). Thanks for the hard work !

hawkonetang commented 1 month ago

Hello! I wonder if the graphics cards of series 20 cannot be used. The prompt is: Custom sampler (advanced). expected scalar type Half but found BFloat16 @balazik

ThisCodeIsMine commented 3 weeks ago

I have the same error message. Is there anything you can do @balazik . I'm so close on making it work... :)


## System Information
- **ComfyUI Version:** v0.2.4-6-g5281090
- **Arguments:** ComfyUI\main.py --windows-standalone-build
- **OS:** nt
- **Python Version:** 3.11.9 (tags/v3.11.9:de54cf5, Apr  2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)]
- **Embedded Python:** true
- **PyTorch Version:** 2.3.1+cu121
## Devices

- **Name:** cuda:0 NVIDIA GeForce RTX 2080 Ti : cudaMallocAsync
  - **Type:** cuda
  - **VRAM Total:** 11810832384
  - **VRAM Free:** 1715076544
  - **Torch VRAM Total:** 8589934592
  - **Torch VRAM Free:** 14015936

  2024-10-26 17:58:12,152 - root - INFO - got prompt
2024-10-26 17:58:12,194 - root - INFO - Using pytorch attention in VAE
2024-10-26 17:58:12,195 - root - INFO - Using pytorch attention in VAE
2024-10-26 17:58:12,742 - root - INFO - model weight dtype torch.bfloat16, manual cast: torch.float16
2024-10-26 17:58:12,742 - root - INFO - model_type FLUX
2024-10-26 17:58:17,249 - root - INFO - Requested to load FluxClipModel_
2024-10-26 17:58:17,249 - root - INFO - Loading 1 new model
2024-10-26 17:58:21,688 - root - INFO - loaded completely 0.0 3962.80810546875 True
2024-10-26 17:58:24,062 - root - INFO - Loaded EVA02-CLIP-L-14-336 model config.
2024-10-26 17:58:24,080 - root - INFO - Shape of rope freq: torch.Size([576, 64])
2024-10-26 17:58:28,668 - root - INFO - Loading pretrained EVA02-CLIP-L-14-336 weights (eva_clip).
2024-10-26 17:58:29,444 - root - INFO - incompatible_keys.missing_keys: ['visual.rope.freqs_cos', 'visual.rope.freqs_sin', 'visual.blocks.0.attn.rope.freqs_cos', 'visual.blocks.0.attn.rope.freqs_sin', 'visual.blocks.1.attn.rope.freqs_cos', 'visual.blocks.1.attn.rope.freqs_sin', 'visual.blocks.2.attn.rope.freqs_cos', 'visual.blocks.2.attn.rope.freqs_sin', 'visual.blocks.3.attn.rope.freqs_cos', 'visual.blocks.3.attn.rope.freqs_sin', 'visual.blocks.4.attn.rope.freqs_cos', 'visual.blocks.4.attn.rope.freqs_sin', 'visual.blocks.5.attn.rope.freqs_cos', 'visual.blocks.5.attn.rope.freqs_sin', 'visual.blocks.6.attn.rope.freqs_cos', 'visual.blocks.6.attn.rope.freqs_sin', 'visual.blocks.7.attn.rope.freqs_cos', 'visual.blocks.7.attn.rope.freqs_sin', 'visual.blocks.8.attn.rope.freqs_cos', 'visual.blocks.8.attn.rope.freqs_sin', 'visual.blocks.9.attn.rope.freqs_cos', 'visual.blocks.9.attn.rope.freqs_sin', 'visual.blocks.10.attn.rope.freqs_cos', 'visual.blocks.10.attn.rope.freqs_sin', 'visual.blocks.11.attn.rope.freqs_cos', 'visual.blocks.11.attn.rope.freqs_sin', 'visual.blocks.12.attn.rope.freqs_cos', 'visual.blocks.12.attn.rope.freqs_sin', 'visual.blocks.13.attn.rope.freqs_cos', 'visual.blocks.13.attn.rope.freqs_sin', 'visual.blocks.14.attn.rope.freqs_cos', 'visual.blocks.14.attn.rope.freqs_sin', 'visual.blocks.15.attn.rope.freqs_cos', 'visual.blocks.15.attn.rope.freqs_sin', 'visual.blocks.16.attn.rope.freqs_cos', 'visual.blocks.16.attn.rope.freqs_sin', 'visual.blocks.17.attn.rope.freqs_cos', 'visual.blocks.17.attn.rope.freqs_sin', 'visual.blocks.18.attn.rope.freqs_cos', 'visual.blocks.18.attn.rope.freqs_sin', 'visual.blocks.19.attn.rope.freqs_cos', 'visual.blocks.19.attn.rope.freqs_sin', 'visual.blocks.20.attn.rope.freqs_cos', 'visual.blocks.20.attn.rope.freqs_sin', 'visual.blocks.21.attn.rope.freqs_cos', 'visual.blocks.21.attn.rope.freqs_sin', 'visual.blocks.22.attn.rope.freqs_cos', 'visual.blocks.22.attn.rope.freqs_sin', 'visual.blocks.23.attn.rope.freqs_cos', 'visual.blocks.23.attn.rope.freqs_sin']
2024-10-26 17:58:31,844 - root - INFO - Loading PuLID-Flux model.
2024-10-26 17:58:39,170 - root - INFO - Requested to load Flux
2024-10-26 17:58:39,170 - root - INFO - Loading 1 new model
2024-10-26 17:58:47,553 - root - INFO - loaded completely 0.0 7276.8634033203125 True
2024-10-26 17:58:48,340 - root - ERROR - !!! Exception during processing !!! expected scalar type Half but found BFloat16
2024-10-26 17:58:48,345 - root - ERROR - Traceback (most recent call last):
  File "C:\Program Files\ComfyUI_windows_portable\ComfyUI\execution.py", line 323, in execute
ThisCodeIsMine commented 3 weeks ago

Hello! I wonder if the graphics cards of series 20 cannot be used. The prompt is: Custom sampler (advanced). expected scalar type Half but found BFloat16 @balazik Did you already found a solution? I get the same error with all updated files. Using a NVIDIA GeForce RTX 2080 Ti. I don't know what the problem could be but I'm sure there must be only a configuration that can be adapted.