stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Bug]: Upscaling fails on Apple Silicon

Open appwagner opened this issue 1 year ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What happened?

Python crashes when upscaling is run from a base resolution of 512x1024. Upscaling does seem to work for 512x512.

Steps to reproduce the problem

  1. Input any prompt
  2. Select any upscaler
  3. Set image to 512x1024
  4. Generate an image

What should have happened?

Upscaling should have completed successfully

Commit where the problem happens

5ab7f213  

What platforms do you use to access the UI ?

MacOS

What browsers do you use to access the UI ?

Mozilla Firefox

Command Line Arguments

--skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate

List of extensions

None. This fails using absolutely nothing other than the base stable diffusion model.

Console logs

./webui.sh                                                                                

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on XXXXXX user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Python 3.10.11 (main, Apr  7 2023, 07:24:53) [Clang 14.0.0 (clang-1400.0.29.202)]
Commit hash: 5ab7f213bec2f816f9c5644becb32eb72c8ffb89
Installing requirements
Launching Web UI with arguments: --skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate
Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled
No module 'xformers'. Proceeding without it.
Loading weights [f300684443] from /Users/apwagner/Projects/stable-diffusion-webui/models/Stable-diffusion/f222.safetensors
Creating model from config: /Users/apwagner/Projects/stable-diffusion-webui/configs/v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying cross attention optimization (InvokeAI).
Textual inversion embeddings loaded(0): 
Model loaded in 1.8s (load weights from disk: 0.2s, create model: 0.5s, apply weights to model: 0.4s, apply half(): 0.2s, move model to device: 0.5s).
Running on local URL:  http://127.0.0.1:7860
100%|ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ| 20/20 [00:26<00:00,  1.32s/it]
  0%|                                                                                                                     | 0/20 [00:00<?, ?it/s]/AppleInternal/Library/BuildRoots/9941690d-bcf7-11ed-a645-863efbbaf80d/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MPSCore/Types/MPSNDArray.mm:706: failed assertion `[MPSTemporaryNDArray initWithDevice:descriptor:] Error: NDArray dimension length > INT_MAX'0:30,  1.26s/it]
zsh: abort      ./webui.shâââââââââââââââââââââ                                                                  | 11/40 [00:23<00:38,  1.33s/it]
(base) apwagner@Andrews-MBP-2 stable-diffusion-webui % /opt/homebrew/Cellar/[email protected]/3.10.11/Frameworks/Python.framework/Versions/3.10/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 '

Additional information

No response

appwagner avatar May 05 '23 12:05 appwagner

+1

husseinsharif avatar May 05 '23 15:05 husseinsharif

+1

minorbug avatar May 07 '23 05:05 minorbug

This is because your mac has insufficient resources to generate this picture. So either do not generate such a large picture, or you need to use a better mac

dongweiming avatar May 18 '23 10:05 dongweiming

@dongweiming That's untrue. This is a limitation of the MPS backend:

/AppleInternal/Library/BuildRoots/9941690d-bcf7-11ed-a645-863efbbaf80d/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MPSCore/Types/MPSNDArray.mm:706: failed assertion `[MPSTemporaryNDArray initWithDevice:descriptor:] Error: NDArray dimension length > INT_MAX

akx avatar May 28 '23 13:05 akx

@dongweiming That's untrue. This is a limitation of the MPS backend:

/AppleInternal/Library/BuildRoots/9941690d-bcf7-11ed-a645-863efbbaf80d/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MPSCore/Types/MPSNDArray.mm:706: failed assertion `[MPSTemporaryNDArray initWithDevice:descriptor:] Error: NDArray dimension length > INT_MAX

Getting the same error when doing "Hires. fix" but after a bit of testing I figured it only dies when I use Doggettx as cross attention optimization.

When leaving to Auto (which picks InvokeAI in my case) it upscales with no issues to a reasonable resolution within my HW specs (32gb ram on macmini m2 pro).

I had the exact same issue with Vlad's Automatic but InvokeAI fixes it there too.

mariodian avatar May 31 '23 02:05 mariodian