Comments (49)
To summarize on how to install MLX currently using the PyPI packages:
- You need a machine with an M-series chip
- OS >= 13.0
- Python between 3.8-3.11
If you meet those requirements and it still doesn't work, make sure you are using a native python. The output of:
python -c "import platform; print(platform.processor())"
should be arm
.
from mlx.
My problem is fixed. I was running iTerm on rosetta and Homebrew and all the installed packages (including python versions) were all i386 versions. I now switched completely to arm builds and pip install mlx
installs correctly and imports just fine. Thank you all :)
from mlx.
python -c "import platform; print(platform.processor())"
This seems like something that should be mentioned in the readme/docs in BOLD.
I didn't use a native Python, but the following worked for me:
CONDA_SUBDIR=osx-arm64 conda create -n AppleMLX python=3.11
from mlx.
I am having the same issue on a Macbook Air 2020 M1 with a fresh python 3.11 virtual environment.
pip only downloads v.0.0.0 of mlx.
tried the following commands after upgrading pip as pip install --upgrade pip
(not in this order):
pip install mlx
pip --force-reinstall --no-cache-dir --upgrade mlx
pip install mlx==0.0.3
all of the above commands somehow downloads the v0.0.0.
ProductName: macOS
ProductVersion: 13.5.1
BuildVersion: 22G90
from mlx.
I've created a new conda env and now i'm getting the following error message
pip install mlx
ERROR: Could not find a version that satisfies the requirement mlx (from versions: none)
ERROR: No matching distribution found for mlx
Even tried pip install mlx==0.0.3
ERROR: Could not find a version that satisfies the requirement mlx==0.0.3 (from versions: none)
ERROR: No matching distribution found for mlx==0.0.3
Python version: 3.10.13
Pip version: 23.3.1
Macbook air M1 2020 with 8GB memory running Sonoma 14.0
Build version: 23A344
from mlx.
Just another (positive) data point: I had no issue with pip install -U mlx
on a fresh conda environment.
pip install -U mlx
Collecting mlx
Downloading mlx-0.0.3-cp311-cp311-macosx_13_0_arm64.whl.metadata (212 bytes)
Downloading mlx-0.0.3-cp311-cp311-macosx_13_0_arm64.whl (9.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.4/9.4 MB 4.7 MB/s eta 0:00:00
Installing collected packages: mlx
Successfully installed mlx-0.0.3
Python 3.11.6 | packaged by conda-forge | (main, Oct 3 2023, 10:37:07) [Clang 15.0.7 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mlx.core as mx
>>> a = mx.array([1, 2, 3, 4])
>>> a.shape
[4]
>>> a.dtype
int32
OS: macOS 13.5.2
Host: MacBookPro17,1
Kernel: 22.6.0
CPU: Apple M1
GPU: Apple M1
Python 3.11.6
conda 23.9.0
from mlx.
It looks like we don't have a wheel for python 12. So for now you can do:
conda create -n myenv python=3.11
conda activate myenv
pip install mlx
We will add a wheel for python 12 ASAP
from mlx.
I've created a new conda env and now i'm getting the following error message
pip install mlx
ERROR: Could not find a version that satisfies the requirement mlx (from versions: none)
ERROR: No matching distribution found for mlx
Even triedpip install mlx==0.0.3
ERROR: Could not find a version that satisfies the requirement mlx==0.0.3 (from versions: none)
ERROR: No matching distribution found for mlx==0.0.3
Python version: 3.10.13 Pip version: 23.3.1 Macbook air M1 2020 with 8GB memory running Sonoma 14.0 Build version: 23A344Can you also try using
pip3 install mlx
orpython3.10 -m pip install mlx
and let me know if that helps ?
Nope still getting the same error
from mlx.
I was hitting this and then realized it was because my pyenv/python/pip were all running under rosetta. You can check this with:
python -c "import platform; print(platform.processor())"
If you get back arm
it's the non-rosetta version. If you get back i386
it is and you will have to use a non-rosetta python/pip.
If you're in deep with pyenv and pyenv-virtualenv I recommend setting a new PYENV_ROOT
for your non-rosetta python versions and venvs and then re-evalling the pyenv init and pyenv virtualenv-inits.
from mlx.
I did but that doesn't seem to work either
from mlx.
It looks like we don't have a wheel for python 12. So for now you can do:
conda create -n myenv python=3.11 conda activate myenv pip install mlx
We will add a wheel for python 12 ASAP
Your solution works for me. Thanks!
from mlx.
This seems to have worked for me python3.10 -m pip install mlx
, installed the right package.
from mlx.
I was hitting this and then realized it was because my pyenv/python/pip were all running under rosetta. You can check this with:
python -c "import platform; print(platform.processor())"
y@u x[main*] $ python -c "import platform; print(platform.processor())"
arm
As I learned, the problem on my side in OSX version, I'm still on Big Sur, but you have build only for 13.x and 14.x.
from mlx.
@oliverks your OS is below the supported versions. Your best bet is to update to macOS 13 or 14.
from mlx.
The install docs are updated to include the issues brought up in this thread. I am going to close this for now, but feel free to reopen if there are new issues with installation.
from mlx.
Hmm very weird, it looks like it might have been a problem with VSCode. I was importing mlx on a jupyter notebook in VSCode and I was getting the above error I mentioned. I moved out of VSCode, and opened a notebook with the conda environment I initially created with an arm
arch. I was able to successfully import mlx and I was even able to import mlx using Python in the terminal so it seems like a VSCode issue.
Update: I got it to work on VSCode by following @awni your steps to create a fresh env, thanks for the help :)
from mlx.
I found an easy fix to this issue:
if you see i386
when you run this command: python3 -c "import platform; print(platform.processor())"
Just Download & install macOS 64-bit universal2 installer
Once done, you should see arm
now when you rerun: python3 -c "import platform; print(platform.processor())
Now try pip install mlx , it should work.
from mlx.
I use conda install -c conda-forge mlx
, it work.
from mlx.
I am finding the same issue. init.py is print("HELLO WORLD").
from mlx.
Can you try installing the latest version of mlx (pip install -U mlx
) and let me know if the problem still persists ?
from mlx.
What was the result of running pip install -U mlx
? Maybe we can try forcing pip install -U mlx==0.0.3
instead ?
Also, can I ask what MacOS version you are using ?
from mlx.
>> pip install -U mlx
Requirement already satisfied: mlx in ~/opt/anaconda3/envs/test/lib/python3.9/site-packages (0.0.0)
>> pip install -U mlx==0.0.3
ERROR: Could not find a version that satisfies the requirement mlx==0.0.3 (from versions: 0.0.0)
ERROR: No matching distribution found for mlx==0.0.3
Env:
OS: macOS 14.1.1 23B81 arm64
Host: MacBookAir10,1
Kernel: 23.1.0
CPU: Apple M1
GPU: Apple M1
Memory: 1507MiB / 8192MiB
Python 3.9.18
conda 4.10.3
from mlx.
Hmm, that's odd
mlx==0.0.0 is an invalid distribution and pypi has the correct mlx==0.0.2 and mlx==0.0.3 for macOS 14
Let's upgrade pip and make sure it's not using the cached distribution
pip install --upgrade pip
pip install --force-reinstall --no-cache-dir --upgrade mlx
from mlx.
Package Version
mlx 0.0.3
>>> import mlx.core as mx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/vigneshsairoshanande/Desktop/Coding and DS/mlx/mlx.py", line 1, in <module>
import mlx.core as mx
ModuleNotFoundError: No module named 'mlx.core'; 'mlx' is not a package
don't know why but for some reason it's not able to recognize the package
M2 Pro
from mlx.
Hmm, that's odd mlx==0.0.0 is an invalid distribution and pypi has the correct mlx==0.0.2 and mlx==0.0.3 for macOS 14 Let's upgrade pip and make sure it's not using the cached distribution
pip install --upgrade pip
pip install --force-reinstall --no-cache-dir --upgrade mlx
This does not work either.
@jagrit06 I tried installing it from source using pip install -e .
and other commands given here https://ml-explore.github.io/mlx/build/html/install.html# . Even that seems to give an error here
xcrun: error: unable to find utility "metal", not a developer tool or in PATH
make[2]: *** [mlx/backend/metal/kernels/copy.air] Error 72
make[1]: *** [mlx/backend/metal/kernels/CMakeFiles/mlx-metallib.dir/all] Error 2
make: *** [all] Error 2
Traceback (most recent call last):
File "~/opt/anaconda3/envs/test/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install']' returned non-zero exit status 2.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for mlx
Failed to build mlx
ERROR: Could not build wheels for mlx, which is required to install pyproject.toml-based projects
Maybe I should upgrade my python version for more support, but the above trace suggests that metal is not available, not sure why?
from mlx.
Hmm, that's odd mlx==0.0.0 is an invalid distribution and pypi has the correct mlx==0.0.2 and mlx==0.0.3 for macOS 14 Let's upgrade pip and make sure it's not using the cached distribution
pip install --upgrade pip
pip install --force-reinstall --no-cache-dir --upgrade mlx
This does not work either.
@jagrit06 I tried installing it from source using
pip install -e .
and other commands given here https://ml-explore.github.io/mlx/build/html/install.html# . Even that seems to give an error herexcrun: error: unable to find utility "metal", not a developer tool or in PATH make[2]: *** [mlx/backend/metal/kernels/copy.air] Error 72 make[1]: *** [mlx/backend/metal/kernels/CMakeFiles/mlx-metallib.dir/all] Error 2 make: *** [all] Error 2 Traceback (most recent call last): File "~/opt/anaconda3/envs/test/lib/python3.9/subprocess.py", line 528, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install']' returned non-zero exit status 2. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for mlx Failed to build mlx ERROR: Could not build wheels for mlx, which is required to install pyproject.toml-based projects
Maybe I should upgrade my python version for more support, but the above trace suggests that metal is not available, not sure why?
Building from source requires that you have a working Xcode installation which provides the metal
and metallib
utilities - could it be possible that that is missing ?
What is the output from running xcode-select -p
?
from mlx.
Hi!
I have the same problem with python installed using pyenv
toolkit.
y@u x[main*] $ pip install --upgrade pip
Requirement already satisfied: pip in /Users/y/.pyenv/versions/3.10.1/lib/python3.10/site-packages (23.3.1)
y@u x[main*] $ pip install -U mlx
Requirement already satisfied: mlx in /Users/y/.pyenv/versions/3.10.1/lib/python3.10/site-packages (0.0.0)
also the same problem with native python:
y@u x[main*] $ /usr/bin/python3 -m pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /Users/y/Library/Python/3.8/lib/python/site-packages (23.3.1)
y@u x[main*] $ /usr/bin/python3 -m pip install mlx -U
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: mlx in /Users/y/Library/Python/3.8/lib/python/site-packages (0.0.0)
OS Version is:
y@u x[main*] $ sw_vers
ProductName: macOS
ProductVersion: 11.7.7
BuildVersion: 20G1345
from mlx.
I'm having the exact same problem in a newly created condo env.
Update: I have succeeded in installing it and runing the stable diffusion example with the Mac system python.
from mlx.
I upgraded pip and tried this
(enc) (base) MacBook-Pro-4:stable_diffusion oliverks$ pip install -U mlx==0.0.3
ERROR: Could not find a version that satisfies the requirement mlx==0.0.3 (from versions: 0.0.0)
ERROR: No matching distribution found for mlx==0.0.3
My OS is
ProductName: macOS
ProductVersion: 12.6
BuildVersion: 21G115
from mlx.
I encountered the same problem. I used pip install mlx
to install and when I tried to run python main.py
in mnist, the following output appeared:
HELLO WORLD!
Traceback (most recent call last):
File "/Users/renyi/Code/mlx-examples/mnist/main.py", line 8, in <module>
import mlx.core as mx
ModuleNotFoundError: No module named 'mlx.core'
Here are some information about my machine and environment
MacBook Air M2 with 24GB memory
ProductName: macOS
ProductVersion: 14.1.1
BuildVersion: 23B81
Python Version: 3.12.0
Pip Version: 23.3.1
from mlx.
I used pip3 wherever I saw pip and it worked perfectly.
from mlx.
I've created a new conda env and now i'm getting the following error message
pip install mlx
ERROR: Could not find a version that satisfies the requirement mlx (from versions: none)
ERROR: No matching distribution found for mlx
Even triedpip install mlx==0.0.3
ERROR: Could not find a version that satisfies the requirement mlx==0.0.3 (from versions: none)
ERROR: No matching distribution found for mlx==0.0.3
Python version: 3.10.13 Pip version: 23.3.1 Macbook air M1 2020 with 8GB memory running Sonoma 14.0 Build version: 23A344
Can you also try using pip3 install mlx
or python3.10 -m pip install mlx
and let me know if that helps ?
from mlx.
@NilayGaitonde could you run:
pip debug --verbose
It should show you what pip thinks your machine is compatible with. We're looking for something like:
cp310-cp310-macosx_13_0_arm64
from mlx.
When I run that command I get a bunch of
co3x
where x is between 2 and 8, and I see no mention of arm in any of the outputs.
from mlx.
OK great, that was a duh moment, my version was still x86. So I used python3.11 natively which is arm. I now see
cp311-cp311-macosx_12_0_arm64
on the version, but it can't find mlx. I get
(enc) (base) MacBook-Pro-4:mlx oliverks$ pip install mlx
ERROR: Could not find a version that satisfies the requirement mlx (from versions: none)
ERROR: No matching distribution found for mlx
from mlx.
Hey!! yes the problem was fixed thank you! I guess I had the wrong conda architecture on my mac and so was getting i386
on running python -c "import platform; print(platform.processor())"
on switching it back to arm I was able to download the correct package. Thank you for your help!!
from mlx.
Alternatively, including the xcode-select path also helps with this issue.
from mlx.
I'm currently running into this error when I'm trying to import mlx:
import mlx.core as mx
ImportError: dlopen(/Users/you/opt/anaconda3/envs/native/lib/python3.12/site-packages/mlx/core.cpython-312-darwin.so, 0x0002): tried: '/Users/you/opt/anaconda3/envs/native/lib/python3.12/site-packages/mlx/core.cpython-312-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
I followed the directions above and created a conda env using the arm arch. I followed the directions from this post. For some context, I'm running:
Python version: 3.12.0
Pip version: 23.3.2
Macbook Pro M1 2020 with 8GB memory running Sonoma 14.2.1
from mlx.
Not sure what's going on there. It looks like your environment might be a bit wonky though.
I would try making a fresh conda environment. Make sure the below gives arm
python -c "import platform; print(platform.processor())"
Then python -m pip install mlx
Let me know if you figure out the problem and what it ended up being!
from mlx.
Issue Description:
I created a Python 3.9
virtual environment using miniconda
and successfully installed mlx
.
However, when I try to import mlx.core
, I encounter an error.
Based on the error message, should I update my Mac OS version?
Environment:
- Apple M1 Pro 16G
- macOS 13.0 (22A380)
- Python
Python 3.9.18 | packaged by conda-forge | (main, Dec 23 2023, 16:35:41)
[Clang 16.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Error Message:
>>> import mlx.core as mx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/cuinuan/miniconda3/envs/labelimg/lib/python3.9/site-packages/mlx/core.cpython-39-darwin.so, 0x0002): Symbol not found: _cblas_sgemm$NEWLAPACK
Referenced from: <C3D30763-555E-35AD-B21B-85F410FA8F82> /Users/cuinuan/miniconda3/envs/labelimg/lib/python3.9/site-packages/mlx/lib/libmlx.dylib (built for macOS 13.3 which is newer than running OS)
Expected in: <E6C2D470-8878-372D-B9DB-0EDCA1303272> /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
>>> import mlx
>>>
Other Information:
python -c "import platform; print(platform.processor())"
arm
from mlx.
macOS 13.0 (22A380)
I would update your OS and try a gain. We officially support OS 13.5 and higher.
from mlx.
any solution for windows 11?
Specs:
python -c "import platform; print(platform.processor())"
AMD64 Family 25 Model 80 Stepping 0, AuthenticAMD
from mlx.
Unfortunately not. Apple silicon is the primary focus. You could probably get things working on linux without much difficulty building from source. But beyond that, we are not supporting other platforms for the time being.
from mlx.
macOS 13.0 (22A380)
I would update your OS and try a gain. We officially support OS 13.5 and higher.
I wonder why it couldn't work under osx Monterey (12.*) if PyTorch natively works under Osx Monterey (e.g. allows you to move nn.Module to nps device) ?
from mlx.
python 3.11 is not working for me
- created new virtual environment w/ python 3.11
- activated and ran pip install
- failed: couldn't find mlx, as before with python 3.12 🤔
(.venv) ➜ mistral git:(main) python3.11 -m pip install -r requirements.txt
ERROR: Could not find a version that satisfies the requirement mlx>=0.8.0 (from versions: none)
ERROR: No matching distribution found for mlx>=0.8.0
(.venv) ➜ mistral git:(main) python3.11 --version
Python 3.11.9
from mlx.
Did you check this issue #200 ? Most likely you are running python via rosetta for x86:
python -c "import platform; print(platform.processor())"
Should print arm
.
Check out the installation instructions for more troubleshooting tips
from mlx.
Did you check this issue #200 ? Most likely you are running python via rosetta for x86:
python -c "import platform; print(platform.processor())"
Should print
arm
.
Yep tried this, prints arm
, still no luck.
Check out the installation instructions for more troubleshooting tips
Thanks! Will update this thread w/ the solution if i can get it working
from mlx.
Make sure you are using the same python:
python3.11 -c "import platform; print(platform.processor())"
from mlx.
python 3.11 is not working for me
- created new virtual environment w/ python 3.11
- activated and ran pip install
- failed: couldn't find mlx, as before with python 3.12 🤔
(.venv) ➜ mistral git:(main) python3.11 -m pip install -r requirements.txt ERROR: Could not find a version that satisfies the requirement mlx>=0.8.0 (from versions: none) ERROR: No matching distribution found for mlx>=0.8.0 (.venv) ➜ mistral git:(main) python3.11 --version Python 3.11.9
OK the issue was that I was on macOS 12 and mlx requires 13+.
✅ Working now after updating to macOS 14. Thanks @awni 🙏
from mlx.
Related Issues (20)
- [Feature] Make APIs non-blocking HOT 3
- [Feature] Enable Metal argsort, sort for > 2M elements along an axis
- [Feature] searchsorted HOT 4
- [Feature Request] Support convolution backward for groups > 1. HOT 1
- [BUG] 'mlx.core.linalg.qr' doesn't work on gpu, there's an abort. HOT 1
- [BUG] HOT 8
- [BUG] type stubs are missing for python 3.9 and 3.10 distributions
- [Feature Request] Adding option to follow PyTorch API in GELU initalization HOT 1
- [BUG] Segmentation fault while running custom operations HOT 4
- Memory Leakage Issue in MLX 0.16 HOT 9
- [PERFORMANCE] grads for bitwise ops + indexing HOT 1
- [Performance] Linear Layer Benchmark HOT 2
- [BUG] expm1 handling of overflow / underflow causes wrong results
- [Feature Request] mx.pad supports the "edge" padding mode.
- [BUG] Cannot use mlx.metallib from xcode MacOS project (Swift, C++)
- [BUG] Cannot convert a list with `None` to `mx.array` HOT 1
- [BUG] Docs not building HOT 4
- How can we enable w4a8 GEMM in MLX? HOT 6
- Missing pyi file for mlx.core HOT 1
- Performance Comparison Issue: Matrix Multiplication on MLX vs. PyTorch on Mac HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mlx.