Skip to main content

Installation

MLX is available on PyPI with platform-specific packages for macOS and Linux. Choose the installation method that matches your platform and requirements.

macOS (Apple Silicon)

MLX runs natively on Apple silicon Macs using the Metal GPU backend.

Requirements

  • M-series chip (Apple silicon)
  • macOS >= 14.0
  • Python >= 3.10 (native, not x86 via Rosetta)

Install with pip

pip install mlx
MLX is only available on devices running macOS 14.0 or higher.

Verify Python Architecture

Ensure you’re using native Python (not running via Rosetta):
python -c "import platform; print(platform.processor())"
The output should be arm. If it shows i386, you’re using a non-native Python. Switch to a native Python installation using Conda or another package manager.

Linux

MLX supports Linux with CUDA GPU acceleration or CPU-only execution.

CUDA Backend

For NVIDIA GPUs with CUDA support:

Requirements

  • NVIDIA architecture >= SM 7.5
  • NVIDIA driver >= 550.54.14
  • CUDA toolkit >= 12.0
  • Linux distribution with glibc >= 2.35
  • Python >= 3.10

Install with pip

pip install mlx[cuda12]
CUDA 13 requires an NVIDIA driver >= 580 or an appropriate CUDA compatibility package.

CPU-Only Backend

For running MLX on Linux without GPU acceleration:

Requirements

  • Linux distribution with glibc >= 2.35
  • Python >= 3.10

Install with pip

pip install mlx[cpu]

Troubleshooting

If your OS and Python versions meet the requirements but pip still fails, you’re likely using a non-native Python.Check your Python architecture:
python -c "import platform; print(platform.processor())"
On macOS with Apple silicon, this should output arm. If it shows i386, switch to a native Python installation.
Ensure you’re using Python 3.10 or later:
python --version
On macOS, verify you’re running macOS 14.0 or higher:
sw_vers

Building from Source

For advanced users who need to build from source, MLX supports custom builds with various configuration options.

Requirements

  • C++ compiler with C++20 support (e.g., Clang >= 15.0)
  • CMake >= 3.25
  • macOS: Xcode >= 15.0 with macOS SDK >= 14.0
  • Linux (CPU): BLAS and LAPACK libraries
  • Linux (CUDA): CUDA toolkit and cuDNN

Clone and Build

1

Clone the repository

git clone git@github.com:ml-explore/mlx.git mlx && cd mlx
2

Install with pip

For development:
pip install -e ".[dev]"
For CUDA on Linux:
CMAKE_ARGS="-DMLX_BUILD_CUDA=ON" pip install -e ".[dev]"
3

Run tests

python -m unittest discover python/tests
For detailed C++ build instructions and advanced configuration options, see the Build from Source documentation.

Next Steps

Quick Start Tutorial

Learn how to create your first MLX arrays and perform basic operations