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
56.93k stars 6.04k forks source link

--force-upcast-attention fixes black images on Mac Mini m1 2020, reporting because asked by --help #4799

Open krypt-lx opened 2 months ago

krypt-lx commented 2 months ago

Expected Behavior

Image successfully generated

Actual Behavior

output image image is black, but using "--force-upcast-attention" option fixes the black screen

Steps to Reproduce

Number of steps is set to 30, step 30, sampler - DDPM, scheduler - Karras (or any other combination, actually, all is required is enough steps)

--help asks me to report this issue if "--force-upcast-attention" fixes things, so I do.

Debug Logs

notwork@MacMini ComfyUI % ./venv/bin/python main.py                         
[START] Security scan
[DONE] Security scan
## ComfyUI-Manager: installing dependencies done.
** ComfyUI startup time: 2024-09-05 21:29:55.683236
** Platform: Darwin
** Python version: 3.9.6 (default, Nov 10 2023, 13:38:27) 
[Clang 15.0.0 (clang-1500.1.0.2.5)]
** Python executable: /Users/notwork/ComfyUI/ComfyUI/venv/bin/python
** ComfyUI Path: /Users/notwork/ComfyUI/ComfyUI
** Log path: /Users/notwork/ComfyUI/ComfyUI/comfyui.log

Prestartup times for custom nodes:
   0.5 seconds: /Users/notwork/ComfyUI/ComfyUI/custom_nodes/ComfyUI-Manager

Total VRAM 16384 MB, total RAM 16384 MB
pytorch version: 2.5.0.dev20240903
Set vram state to: SHARED
Device: mps
Using sub quadratic optimization for cross attention, if you have memory or speed issues try using: --use-split-cross-attention
[Prompt Server] web root: /Users/notwork/ComfyUI/ComfyUI/web
/Users/notwork/ComfyUI/ComfyUI/venv/lib/python3.9/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)
### Loading: ComfyUI-Manager (V2.50.3)
### ComfyUI Revision: 2647 [22d1241a] | Released on '2024-09-04'

Import times for custom nodes:
   0.0 seconds: /Users/notwork/ComfyUI/ComfyUI/custom_nodes/websocket_image_save.py
   0.1 seconds: /Users/notwork/ComfyUI/ComfyUI/custom_nodes/ComfyUI-Manager

Starting server

To see the GUI go to: http://127.0.0.1:8188
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/alter-list.json
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/github-stats.json
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/extension-node-map.json
got prompt
model weight dtype torch.float16, manual cast: None
model_type EPS
Using split attention in VAE
Using split attention in VAE
/Users/notwork/ComfyUI/ComfyUI/venv/lib/python3.9/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(
Requested to load SD1ClipModel
Loading 1 new model
loaded completely 0.0 235.84423828125 True
Requested to load BaseModel
Loading 1 new model
loaded completely 0.0 1639.406135559082 True
100%|███████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:42<00:00,  1.42s/it]
Requested to load AutoencoderKL
Loading 1 new model
loaded completely 0.0 319.11416244506836 True
/Users/notwork/ComfyUI/ComfyUI/nodes.py:1498: RuntimeWarning: invalid value encountered in cast
  img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
Prompt executed in 50.80 seconds

Other

Mac Mini M1 2020, 16Gb ram MacOS 13.6.3 (22G436)

Model Identifier: Macmini9,1 Chip: Apple M1 Total Number of Cores: 8 (4 performance and 4 efficiency) Memory: 16 GB System Firmware Version: 10151.61.4 OS Loader Version: 8422.141.2.700.1

krypt-lx commented 2 months ago

Also, FLUX1 refuses to load because no bfloat16 in pytorch support on macos 13

richardtallent commented 1 month ago

Can confirm, this flag added to my ComfyUI backend on SwarmUI seems to have fixed the black images for me. M3 Pro.

For awhile now previously, I was only able to generate in less than around 12 steps, which limited me to SD 1.5 + LCM.