nullquant / ComfyUI-BrushNet

ComfyUI BrushNet nodes
Apache License 2.0
384 stars 14 forks source link

failed assertion `[MPSNDArray initWithDevice:descriptor:] Error: total bytes of NDArray #95

Closed alexcc4 closed 3 weeks ago

alexcc4 commented 1 month ago

workflow: powerpaint remove object device: Mac arm64, mps log:

model_type EPS
Using split attention in VAE
Using split attention in VAE
Requested to load SD1ClipModel
Loading 1 new model
Base model type: SD1.5
BrushNet image.shape = torch.Size([1, 1707, 1280, 3]) mask.shape = torch.Size([1, 1707, 1280])
Requested to load AutoencoderKL
Loading 1 new model
BrushNet CL: image_latents shape = torch.Size([1, 4, 213, 160]) interpolated_mask shape = torch.Size([1, 1, 213, 160])
You should add to positive prompt: "empty scene blur"
Requested to load SD1ClipModel
Loading 1 new model
Requested to load BaseModel
Loading 1 new model
  0%|                                                                                          | 0/20 [00:00<?, ?it/s]BrushNet inference: do_classifier_free_guidance is True False
BrushNet inference, step = 0: image batch = 1, got 1 latents, starting from 0
BrushNet inference: sample torch.Size([1, 4, 213, 160]) , CL torch.Size([1, 5, 213, 160])
/AppleInternal/Library/BuildRoots/ce725a5f-c761-11ee-a4ec-b6ef2fd8d87b/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MPSCore/Types/MPSNDArray.mm:788: failed assertion `[MPSNDArray initWithDevice:descriptor:] Error: total bytes of NDArray > 2**32'
[1]    20151 abort      python main.py
/Users/liangbinsi/.pyenv/versions/3.10.0/lib/python3.10/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '
image
nullquant commented 1 month ago

The issue is connected with pytorch mac implementation.

  1. What mac OS version do you use?
  2. What pytorch version in your ComfyUI installation do you use?
alexcc4 commented 1 month ago
nullquant commented 1 month ago

That is quite old pytorch version. It seems that bug was quite common in previous version of mac OS for some sizes of images, but was gone a year ago. Pytorch 1.9.4 is also a version about a year ago old. So, may be it is time to move to 2.x? :)

alexcc4 commented 1 month ago

I upgraded my dependencies: pytorch-lightning==2.2.4 Still the same error occurs

nullquant commented 1 month ago

This problem is related to the size of the input image and attention calculation in PowerPaint. I added an option to PowerPaint node. Update nodes and try to set save_memory to max. If the problem remains you should use CutForInpaint or resize image.