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

Fix for MTLLibraryErrorDomain Code=1 "Invalid library file" #4373

Closed
wants to merge 4 commits into from

Conversation

mooihi
Copy link

@mooihi mooihi commented May 1, 2024

MTLLibraryErrorDomain Code=1 "Invalid library file" is caused by conda.

Conda python binaries are built with a target for older macOS versions. 11.0 for M series and 10.9 for Intel Macs.

Using otool -L on the conda python binaries show /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1) while the working python binaries (system and homebrew) show /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3).

Conda team does not seem to want to change the target anytime soon.

I managed to build a python binary via conda forge with only a target change for 13.3. And the metal compilation works fine.
Screenshot 2024-05-02 at 12 11 43 AM

As this is a conda issue, the PR sets the XCODE_METAL flag to 1 when conda environment is detected and uses xcrun for metal compilation. Also include a message for users about the conda incompatibility. I’ve tested the performance and it is actually faster to use xcrun although the cost is to install the Xcode library.

Those who had already ran tinygrad on conda before will need to clear cache by deleting ~/Library/Caches/tinygrad/cache.db for this to work. So the DISABLE_COMPILER_CACHE flag is no longer required.

Copy link
Contributor

github-actions bot commented May 1, 2024

Changes

Name                             Lines    Diff    Tokens/Line    Diff
-----------------------------  -------  ------  -------------  ------
tinygrad/runtime/ops_metal.py      102      +2           11.8    -0.1


total lines changes: +2

@mooihi
Copy link
Author

mooihi commented May 3, 2024

@chenyuxyz Can a maintainer take a quick look at this? It can save a new conda user some pain. I am not looking for bounty. Thanks.

@geohot
Copy link
Collaborator

geohot commented May 4, 2024

This is not a fix, and relies on the user having XCODE installed (also becomes slower). I think the current error message in there is fine.

@geohot geohot closed this May 4, 2024
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

Successfully merging this pull request may close these issues.

3 participants