Install dependencies in a dedicated virtual environment
First check that Homebrew is available, then install Python. If Homebrew isn’t installed, follow an installation procedure you’ve verified. Don’t run one-click scripts from unknown sources.
command -v brew
brew --version
brew install python
python3 --version
uname -m
uname -m It should return arm64. If it returns a different architecture, exit the translation environment and check which Python your terminal is using. Don’t mix dependencies across environments.
mkdir -p "$HOME/Projects/mlx-lab"
cd "$HOME/Projects/mlx-lab"
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install mlx mlx-lm
python -m pip check
You’ll need to activate this virtual environment again whenever you open a new terminal. Keep separate environments for different experiments to avoid upgrading dependencies for one project and disrupting another task that’s still running.
Run a minimal operation to check Metal
Run these checks in the environment you just activated. Verify the interpreter path, check whether MLX can detect Metal, then run a GPU array operation.
which python
python -m pip show mlx mlx-lm
python -c 'import mlx.core as mx; print(mx.metal.is_available())'
python -c 'import mlx.core as mx; mx.set_default_device(mx.gpu); x = mx.ones((2, 2)); mx.eval(x + x); print(x + x)'
The Metal check should return True, and the minimal operation should complete successfully. If the import fails, check the Python path and dependencies first. If Metal isn’t available, note your macOS, Python, and MLX versions before submitting a support ticket.
Once the basic environment works, use a local model directory from a trusted source that’s compatible with mlx-lm. Start with a short output test; don’t combine a long context and fine-tuning on your first run.
python -m mlx_lm.generate \
--model "$HOME/Models/my-model" \
--prompt "Explain unified memory in one sentence." \
--max-tokens 128
my-model is a placeholder for your model directory name. Replace it with your own. The directory must include compatible weights, configuration, and tokenizer files; a weights file alone may not be enough.