ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

[Flux] Color noise instead of picture

Open zlobniyshurik opened this issue 1 year ago • 30 comments
trafficstars

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

zlobniyshurik avatar Aug 08 '24 06:08 zlobniyshurik

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.

slezica avatar Aug 10 '24 04:08 slezica

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

orchetect avatar Aug 10 '24 05:08 orchetect

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).

zlobniyshurik avatar Aug 10 '24 09:08 zlobniyshurik

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_

cendywang avatar Aug 10 '24 14:08 cendywang

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/

ender1975 avatar Aug 10 '24 15:08 ender1975

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

gold-silver-copper avatar Aug 13 '24 09:08 gold-silver-copper

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)

zlobniyshurik avatar Aug 13 '24 10:08 zlobniyshurik

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?

srcc-chekh avatar Aug 13 '24 20:08 srcc-chekh

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.

ender1975 avatar Aug 14 '24 01:08 ender1975

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.

fideuacaprichos avatar Aug 14 '24 03:08 fideuacaprichos

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

zlobniyshurik avatar Aug 14 '24 08:08 zlobniyshurik

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.

slezica avatar Aug 14 '24 15:08 slezica

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!

srcc-chekh avatar Aug 14 '24 20:08 srcc-chekh

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.

zwqjoy avatar Aug 15 '24 13:08 zwqjoy

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.

hvaara avatar Aug 15 '24 16:08 hvaara

@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.

zwqjoy avatar Aug 16 '24 01:08 zwqjoy

@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.

hvaara avatar Aug 16 '24 01:08 hvaara

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.

bauerwer avatar Aug 16 '24 09:08 bauerwer

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

hvaara avatar Aug 17 '24 03:08 hvaara

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.

time-less-ness avatar Aug 17 '24 17:08 time-less-ness

@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.

zwqjoy avatar Aug 18 '24 07:08 zwqjoy

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

bnewddt avatar Aug 18 '24 17:08 bnewddt

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

hvaara avatar Aug 18 '24 20:08 hvaara

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

bnewddt avatar Aug 18 '24 20:08 bnewddt

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

bnewddt avatar Aug 18 '24 22:08 bnewddt

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)

RambleRainbow avatar Aug 19 '24 14:08 RambleRainbow

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

geheime avatar Aug 21 '24 04:08 geheime

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

bauerwer avatar Aug 21 '24 13:08 bauerwer

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

I Love you <3

OSZII avatar Aug 21 '24 17:08 OSZII

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.

pedro-rtm avatar Aug 27 '24 18:08 pedro-rtm