Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] EXC_BAD_ACCESS exception when running StableDiffusionExample #153

Open
DaemonLoki opened this issue Nov 6, 2024 · 7 comments
Open

Comments

@DaemonLoki
Copy link

Hey everyone,
when trying to run the StableDiffusionExample I keep on running into the same EXC_BAD_ACCESS exception. This happens on both my M1 MacBook Pro (16GB RAM), as well as my iPhone 16 Pro, so I don't think memory should be an issue.

Model download works, but on weight loading the issue seems to come up.
It happens during execution of the following line:

let latents: DenoiseIterator? = generator.generateLatents(parameters: parameters)

I have taken the project as is w/o modification and the error occurred.

Things I've tried to fix it:

  • update packages to latest versions
  • reduce cache limit on the GPU (e.g. MLX.GPU.set(cacheLimit: 256 * 1024 * 1024))
  • reduce latent size on modelConfiguration

I've had the error appear in different locations (see attached screenshots).
I'm new to the project and would highly appreciated being pointed in any direction to examine further. Thank you already.

Screenshot 2024-11-06 at 16 15 03
Screenshot 2024-11-06 at 16 06 47

@davidkoski
Copy link
Collaborator

Give current head of main a try -- #147 picked up a fix from mlx-are which is likely the cause of this.

@DanteNoguez
Copy link

Running into the same issue with the LLMEval example, even after applying the latest changes in the main branch. I don't see any memory spikes when running it, and it's not utilizing all of the available memory either. Any other ideas @davidkoski?

@davidkoski
Copy link
Collaborator

No, not sure then -- I don't see it here.

Is the call stack of the crash very deep (a couple thousand frames)? If so then at least we know the nature of the problem (very deep call stack, usually recursive evaluation of the graph).

If so the call stack should repeat every couple of frames -- can you grab a screenshot showing the repeating part?

@DanteNoguez
Copy link

Captura de pantalla 2024-11-13 a la(s) 10 02 52 a m

Sure, these are the repeating ones that I see. There are about a hundred of them. And by the way, this issue only occurs when running LLMEval on an iOS simulator; it runs fine on my computer.

Thanks for taking a look!

@davidkoski
Copy link
Collaborator

Ohhhh, simulator!

So not a stack overflow, likely it threw an exception somewhere under there and is shutting down. Short version: it won't work on the simulator because it doesn't support a high enough metal version.

@davidkoski
Copy link
Collaborator

Your best bet may be to use the ability to run iPadOS apps on macOS (if you can't just do the development with macOS directly).

@DanteNoguez
Copy link

Oh, gotcha! Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants