comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
50.32k stars 5.29k forks source link

[Flux] Color noise instead of picture #4263

Closed zlobniyshurik closed 2 weeks ago

zlobniyshurik commented 1 month ago

Expected Behavior

Render beautiful picsture from https://blog.comfy.org/content/images/size/w1000/2024/08/ComfyUI_00006_.png with Flux

Actual Behavior

Got color pixel noise instead of picture with anime girl :)

Steps to Reproduce

  1. Install from scratch ComfyUI
  2. Save picture with anime girl from https://blog.comfy.org/content/images/size/w1000/2024/08/ComfyUI_00006_.png to local storage
  3. Run ComfyUI
  4. Load picture from local storage
  5. Fix paths for vae/model/clip (my files loaded to subdirs, for example /opt/ComfyUI/models/unet/flux1-dev/flux1-dev-fp8.safetensors)
  6. Press Queue Prompt key
  7. Got picture with many random color pixels.

Debug Logs

Total VRAM 20464 MB, total RAM 64193 MB
pytorch version: 2.4.0+rocm6.0
Set vram state to: NORMAL_VRAM
Device: cuda:0 AMD Radeon RX 7900 XT : native
Using sub quadratic optimization for cross attention, if you have memory or speed issues try using: --use-split-cross-attention
[Prompt Server] web root: /opt/ComfyUI/web
/opt/ComfyUI/venv/lib/python3.12/site-packages/kornia/feature/lightglue.py:44: FutureWarning: `torch.cuda.amp.custom_fwd(args...)` is deprecated. Please use `torch.amp.custom_fwd(args..., device_type='cuda')` instead.
  @torch.cuda.amp.custom_fwd(cast_inputs=torch.float32)

Import times for custom nodes:
   0.0 seconds: /opt/ComfyUI/custom_nodes/websocket_image_save.py

Starting server

To see the GUI go to: http://127.0.0.1:8188
got prompt
model weight dtype torch.float8_e4m3fn, manual cast: torch.bfloat16
model_type FLUX
/opt/ComfyUI/venv/lib/python3.12/site-packages/transformers/tokenization_utils_base.py:1601: FutureWarning: `clean_up_tokenization_spaces` was not set. It will be set to `True` by default. This behavior will be depracted in transformers v4.45, and will be then set to `False` by default. For more details check this issue: https://github.com/huggingface/transformers/issues/31884
  warnings.warn(
Model doesn't have a device attribute.
clip missing: ['text_projection.weight']
Requested to load FluxClipModel_
Loading 1 new model
Requested to load Flux
Loading 1 new model
loading in lowvram mode 8051.975
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 26/26 [03:26<00:00,  7.96s/it]
Using split attention in VAE
Using split attention in VAE
Model doesn't have a device attribute.
Requested to load AutoencodingEngine
Loading 1 new model
Prompt executed in 223.88 seconds

Other

System: Fedora 40 (Linux amd64)

  1. I checked CRC of all loaded models/vae/clips - no problems.
  2. Same problem (color pixels) with example from https://blog.comfy.org/content/images/size/w1000/2024/08/ComfyUI_170730_.png
  3. This instance of ComfyUI works perfectly with SDXL models
slezica commented 1 month ago

I have the same problem on a Macbook Pro M3 Max running MacOS Sonoma.

The dev model gives me what looks like random RGB noise. With the schnell model or the fp8 checkpoint I can kinda barely see the image I'm supposed to be getting, but it's super noisy.

The problem goes away when running with --cpu, and I get the same images as in the Flux examples -- but it's unusably slow 😢 .

I'm feel this isn't a ComfyUI problem, but maybe the info helps.

orchetect commented 1 month ago

Same issue on MacBook Pro M1 Max (64GM RAM), macOS 14.6.1 and affects all FLUX.1 models - dev and schnell.

zlobniyshurik commented 1 month ago

Tried to erase venv with python 3.12 and recreate it with python 3.10 inside. No succes. SDXL working, but not Flux (still color noise).

cendywang commented 1 month ago

Also have the problem. The workflow address that I used in here: https://comfyanonymous.github.io/ComfyUI_examples/flux/flux_dev_example.png

When I tried flux1-dev, comfyUI gave me the noises instead of anime girl picture. However, if I switch to flux1-schnell, it works! And the target picture appears!

My env: windows 11 + RTX3090 + 64G RAM; models : flux1-dev + t5xxl_fp16.safetensors + clip_l.safetensors. I also attached the noise picture.

Any help? ComfyUI_temp_bhsmt_00004_

ender1975 commented 1 month ago

I have the same issue as the OP. Running macOS Sonoma 14.6.1.

Might be related to previous issues with Sonoma updates: https://www.reddit.com/r/comfyui/comments/1badrgf/apple_silicon_users_beware_do_not_update_to_macos/

gold-silver-copper commented 1 month ago

downgrade torch as temp fix: pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1

For those having this issue here is a relevant thread where i got the fix: https://github.com/comfyanonymous/ComfyUI/issues/4165#issuecomment-2264948167

zlobniyshurik commented 1 month ago

downgrade torch as temp fix: pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1

For those having this issue here is a relevant thread where i got the fix: #4165 (comment)

Wow! It's working!

  1. I recreated venv with python3.12
  2. pip install torch==2.3.1 torchvision torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/rocm6.0 (there is no binary with torch 2.3.1 for rocm6.1)
  3. pip install -r requirements.txt

First picture is slightly different from blog's reference, but second one - perfect copy

UPD. After rerun I get perfect copy of first reference picture (anime girl showeling snow)

srcc-chekh commented 4 weeks ago

Just tried on macOS 14.6.1 and I tried with torch 2.3.1 and 2.4.0 and 2.5nightly and everything seems to work fine except the final image is just color noise. using example workflow as in this bug

comfyui git clone as of this afternoon. maybe I should try an older comfyui commit?

ender1975 commented 4 weeks ago

downgrade torch as temp fix: pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1

For those having this issue here is a relevant thread where i got the fix: #4165 (comment)

This has worked for me.

fideuacaprichos commented 4 weeks ago

downgrade torch as temp fix: pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1

For those having this issue here is a relevant thread where i got the fix: #4165 (comment)

Up until yesterday it was working if I downgraded, but after I ran Update All today, it only produces noise images after downgrading.

zlobniyshurik commented 4 weeks ago

I just did git pull to the latest version. Still works.

P.S. Linux 64bit 64GB RAM + 7900XT (20GB VRAM) python 3.12 + torch 2.3.1 + torchaudio 2.3.1 + rocm 6.0

slezica commented 4 weeks ago

downgrade torch as temp fix: pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1

For those having this issue here is a relevant thread where i got the fix: #4165 (comment)

Worked for me too, MacOS Sonoma on Macbook Pro M3 Max.

srcc-chekh commented 4 weeks ago

I just did the torch downgrade and also a git pull (got a bunch of changes in ComfyUI in the last 24hrs) and it works now!

zwqjoy commented 4 weeks ago

downgrade torch as temp fix: pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1

Not Worked for me, MacOS Sonoma14.6.1 on Macbook Pro M1 Max. 64g

still noise image.

hvaara commented 3 weeks ago

The noisy images from FLUX on MPS is due to a regression in batch norm. This regressed some time after PyTorch v2.3.1, which is why downgrading works.

Follow https://github.com/pytorch/pytorch/issues/133520 for an update on when the fix is shipped in PyTorch nightly. Please note that this is only relevant for macOS.

zwqjoy commented 3 weeks ago

@hvaara But I downgrade torch : pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1, still noise image, should I wait the Follow https://github.com/pytorch/pytorch/issues/133520 for an update on when the fix is shipped in PyTorch nightly ?

The noisy images from FLUX on MPS is due to a regression in batch norm. This regressed some time after PyTorch v2.3.1, which is why downgrading works.

Follow pytorch/pytorch#133520 for an update on when the fix is shipped in PyTorch nightly. Please note that this is only relevant for macOS.

hvaara commented 3 weeks ago

@zwqjoy What does

import torch
print(torch.__version__)

give you? Some times pip can be a little sneaky and you have two versions installed. You could also try starting from a fresh environment.

bauerwer commented 3 weeks ago

downgrade torch as temp fix: pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1 For those having this issue here is a relevant thread where i got the fix: #4165 (comment)

Up until yesterday it was working if I downgraded, but after I ran Update All today, it only produces noise images after downgrading.

The ComfyUi update a few days ago sets torch=2.4.0 as a requirement and upgrades torch. check if torch is on >=2.4.0 and if so, downgrade back to 2.3.1.

hvaara commented 3 weeks ago

@zwqjoy I got your messages, but looks like they were removed again. Did you get it working?

time-less-ness commented 3 weeks ago

I had the same problem with noise as the output on Mac Studio. I also

pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1

And it seems to be working right. I'll keep an eye on the Pytorch regression bug.

zwqjoy commented 3 weeks ago

@hvaara I git pull the latest comfyui, pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1. and It is OK now.

bnewddt commented 3 weeks ago

I don't know about you guys, but what I get is inconsistent results - Mac studio m2 max / 64gb

Screenshot 2024-08-18 at 8 20 18 PM

hvaara commented 3 weeks ago

@bnewddt can you upload the failure cases somewhere? I'd like to reproduce your results, and the metadata in the images contains the workflow.

bnewddt commented 3 weeks ago

sure @hvaara here you are https://we.tl/t-vtyMxOQUva

bnewddt commented 3 weeks ago

@hvaara installed comfyUI through Pinokio and seems the problems have gone 😅 thanks anyway!

RambleRainbow commented 3 weeks ago

It does work. M3 Pro 128G , MacOS Sequios 15.1

downgrade torch as temp fix: pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1

For those having this issue here is a relevant thread where i got the fix: #4165 (comment)

geheime commented 3 weeks ago

Nothing seems to work for me. Have downgraded and all. Runing a Sonoma Version 14.6.1

bauerwer commented 3 weeks ago

works: downgrade torch as temp fix: pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1 works: torch nightly (at least torch-2.5.0.dev20240821): pip install --upgrade --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu

OSZII commented 3 weeks ago

pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1

I Love you <3

pedro-rtm commented 2 weeks ago

downgrade torch as temp fix: pip install torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1

For those having this issue here is a relevant thread where i got the fix: #4165 (comment)

Thanks! This fixed it.