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

Use MLX inside a Swift playground #89

Open
rounak opened this issue May 20, 2024 · 4 comments
Open

Use MLX inside a Swift playground #89

rounak opened this issue May 20, 2024 · 4 comments

Comments

@rounak
Copy link
Contributor

rounak commented May 20, 2024

I would love to use MLX Swift inside an Xcode playground, to get an environment similar to Jupyter notebooks. However when I try to do this, I get an error:

libc++abi: terminating due to uncaught exception of type std::runtime_error: library not found
Failed to load device library from <default.metallib> or </Users/rounak/Library/Developer/Xcode/DerivedData/FooTest-bkqaiyzcinmaprfeeunnqmandcdl/Build/Intermediates.noindex/Playgrounds/Products/Debug/PackageFrameworks/Cmlx.framework/Versions/A/mlx.metallib>.

You can try to reproduce by cloning this repo: https://github.com/rounak/TestRepoMLXPlayground

@davidkoski
Copy link
Collaborator

I think the problem is that mlx-swift isn't a framework, it is a SPM library. I tried making a new framework in your Xcode project:

image

I also switched mlx-swift to the main branch -- the 0.1 tag is quite old and we haven't been making new tags (maybe we (I) should).

OK, once the framework is created then we can set up a scheme for the playground and tell it to link against that framework. I was looking at this page as I wasn't familiar with how to do that:

image

Anyway, the error comes from the fact that there was no place to attach the resources. You have a command line program and it can link to frameworks but can't contain them.

I was unable to run the playground, but that is because my environment isn't set up properly (with multiple Xcode versions), but I think this might work.

@mahdiaslanimk
Copy link

Can i use mlx in Playgrounds app (iPadOS)?

@Emasoft
Copy link

Emasoft commented Oct 14, 2024

My iPad PRO m4 is waiting for an MLX playground when I can run LLM models and FLUX... please make that possible..🙏

@davidkoski
Copy link
Collaborator

I don't think this is going to be possible on iPad -- you can read about it here.

In order to do this we would need to put all of mlx-swift into the playground so it could build. That is doable, but:

It looks possible on macOS playgrounds

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

4 participants