mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-18 09:58:06 +08:00
docs up
This commit is contained in:

committed by
CircleCI Docs

parent
2aeb6df29c
commit
7534da7269
77
docs/build/html/install.html
vendored
77
docs/build/html/install.html
vendored
@@ -148,9 +148,12 @@
|
||||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Usage</span></p>
|
||||
<ul class="nav bd-sidenav">
|
||||
<li class="toctree-l1"><a class="reference internal" href="usage/quick_start.html">Quick Start Guide</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="usage/lazy_evaluation.html">Lazy Evaluation</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="usage/unified_memory.html">Unified Memory</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="usage/using_streams.html">Using Streams</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="usage/indexing.html">Indexing Arrays</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="usage/saving_and_loading.html">Saving and Loading Arrays</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="usage/numpy.html">Conversion to NumPy and Other Frameworks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="usage/using_streams.html">Using Streams</a></li>
|
||||
</ul>
|
||||
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Examples</span></p>
|
||||
<ul class="nav bd-sidenav">
|
||||
@@ -238,6 +241,7 @@
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.cosh.html">mlx.core.cosh</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.dequantize.html">mlx.core.dequantize</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.divide.html">mlx.core.divide</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.divmod.html">mlx.core.divmod</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.equal.html">mlx.core.equal</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.erf.html">mlx.core.erf</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.erfinv.html">mlx.core.erfinv</a></li>
|
||||
@@ -251,6 +255,7 @@
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.greater.html">mlx.core.greater</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.greater_equal.html">mlx.core.greater_equal</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.identity.html">mlx.core.identity</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.inner.html">mlx.core.inner</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.less.html">mlx.core.less</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.less_equal.html">mlx.core.less_equal</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.linspace.html">mlx.core.linspace</a></li>
|
||||
@@ -261,6 +266,8 @@
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.log1p.html">mlx.core.log1p</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.logaddexp.html">mlx.core.logaddexp</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.logical_not.html">mlx.core.logical_not</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.logical_and.html">mlx.core.logical_and</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.logical_or.html">mlx.core.logical_or</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.logsumexp.html">mlx.core.logsumexp</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.matmul.html">mlx.core.matmul</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.max.html">mlx.core.max</a></li>
|
||||
@@ -273,6 +280,7 @@
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.negative.html">mlx.core.negative</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.ones.html">mlx.core.ones</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.ones_like.html">mlx.core.ones_like</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.outer.html">mlx.core.outer</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.partition.html">mlx.core.partition</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.pad.html">mlx.core.pad</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.prod.html">mlx.core.prod</a></li>
|
||||
@@ -286,6 +294,7 @@
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.save.html">mlx.core.save</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.savez.html">mlx.core.savez</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.savez_compressed.html">mlx.core.savez_compressed</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.save_gguf.html">mlx.core.save_gguf</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.save_safetensors.html">mlx.core.save_safetensors</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.sigmoid.html">mlx.core.sigmoid</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="python/_autosummary/mlx.core.sign.html">mlx.core.sign</a></li>
|
||||
@@ -435,6 +444,7 @@
|
||||
<li class="toctree-l3"><a class="reference internal" href="python/nn/_autosummary_functions/mlx.nn.losses.hinge_loss.html">mlx.nn.losses.hinge_loss</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="python/nn/_autosummary_functions/mlx.nn.losses.huber_loss.html">mlx.nn.losses.huber_loss</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="python/nn/_autosummary_functions/mlx.nn.losses.log_cosh_loss.html">mlx.nn.losses.log_cosh_loss</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="python/nn/_autosummary_functions/mlx.nn.losses.cosine_similarity_loss.html">mlx.nn.losses.cosine_similarity_loss</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -639,6 +649,7 @@ document.write(`
|
||||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#c-api">C++ API</a></li>
|
||||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id2">Troubleshooting</a><ul class="nav section-nav flex-column">
|
||||
<li class="toc-h4 nav-item toc-entry"><a class="reference internal nav-link" href="#metal-not-found">Metal not found</a></li>
|
||||
<li class="toc-h4 nav-item toc-entry"><a class="reference internal nav-link" href="#x86-shell">x86 Shell</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -660,7 +671,7 @@ document.write(`
|
||||
<h2>Install from PyPI<a class="headerlink" href="#install-from-pypi" title="Permalink to this heading">#</a></h2>
|
||||
<p>MLX is available on PyPI. All you have to do to use MLX with your own Apple
|
||||
silicon computer is</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pip<span class="w"> </span>install<span class="w"> </span>mlx
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pip install mlx
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>To install from PyPI you must meet the following requirements:</p>
|
||||
@@ -679,7 +690,7 @@ It is highly recommended to use macOS 14 (Sonoma)</p>
|
||||
<p><em>My OS and Python versions are in the required range but pip still does not find
|
||||
a matching distribution.</em></p>
|
||||
<p>Probably you are using a non-native Python. The output of</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>python<span class="w"> </span>-c<span class="w"> </span><span class="s2">"import platform; print(platform.processor())"</span>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>python -c <span class="s2">"import platform; print(platform.processor())"</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>should be <code class="docutils literal notranslate"><span class="pre">arm</span></code>. If it is <code class="docutils literal notranslate"><span class="pre">i386</span></code> (and you have M series machine) then you
|
||||
@@ -696,37 +707,42 @@ way to do this is with <a class="reference external" href="https://stackoverflow
|
||||
<li><p><a class="reference external" href="https://cmake.org/">cmake</a> – version 3.24 or later, and <code class="docutils literal notranslate"><span class="pre">make</span></code></p></li>
|
||||
<li><p>Xcode >= 14.3 (Xcode >= 15.0 for macOS 14 and above)</p></li>
|
||||
</ul>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
<p>Ensure your shell environment is native <code class="docutils literal notranslate"><span class="pre">arm</span></code>, not <code class="docutils literal notranslate"><span class="pre">x86</span></code> via Rosetta. If
|
||||
the output of <code class="docutils literal notranslate"><span class="pre">uname</span> <span class="pre">-p</span></code> is <code class="docutils literal notranslate"><span class="pre">x86</span></code>, see the <a class="reference internal" href="#build-shell"><span class="std std-ref">troubleshooting section</span></a> below.</p>
|
||||
</div>
|
||||
</section>
|
||||
<section id="python-api">
|
||||
<h3>Python API<a class="headerlink" href="#python-api" title="Permalink to this heading">#</a></h3>
|
||||
<p>To build and install the MLX python library from source, first, clone MLX from
|
||||
<a class="reference external" href="https://github.com/ml-explore/mlx">its GitHub repo</a>:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>git<span class="w"> </span>clone<span class="w"> </span>git@github.com:ml-explore/mlx.git<span class="w"> </span>mlx<span class="w"> </span><span class="o">&&</span><span class="w"> </span><span class="nb">cd</span><span class="w"> </span>mlx
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>git clone git@github.com:ml-explore/mlx.git mlx <span class="o">&&</span> <span class="nb">cd</span> mlx
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Make sure that you have <a class="reference external" href="https://pybind11.readthedocs.io/en/stable/index.html">pybind11</a>
|
||||
installed. You can install <code class="docutils literal notranslate"><span class="pre">pybind11</span></code> with <code class="docutils literal notranslate"><span class="pre">pip</span></code>, <code class="docutils literal notranslate"><span class="pre">brew</span></code> or <code class="docutils literal notranslate"><span class="pre">conda</span></code> as follows:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pip<span class="w"> </span>install<span class="w"> </span><span class="s2">"pybind11[global]"</span>
|
||||
conda<span class="w"> </span>install<span class="w"> </span>pybind11
|
||||
brew<span class="w"> </span>install<span class="w"> </span>pybind11
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pip install <span class="s2">"pybind11[global]"</span>
|
||||
conda install pybind11
|
||||
brew install pybind11
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Then simply build and install it using pip:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>env<span class="w"> </span><span class="nv">CMAKE_BUILD_PARALLEL_LEVEL</span><span class="o">=</span><span class="s2">""</span><span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>.
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>env <span class="nv">CMAKE_BUILD_PARALLEL_LEVEL</span><span class="o">=</span><span class="s2">""</span> pip install .
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>For developing use an editable install:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>env<span class="w"> </span><span class="nv">CMAKE_BUILD_PARALLEL_LEVEL</span><span class="o">=</span><span class="s2">""</span><span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>-e<span class="w"> </span>.
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>env <span class="nv">CMAKE_BUILD_PARALLEL_LEVEL</span><span class="o">=</span><span class="s2">""</span> pip install -e .
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>To make sure the install is working run the tests with:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pip<span class="w"> </span>install<span class="w"> </span><span class="s2">".[testing]"</span>
|
||||
python<span class="w"> </span>-m<span class="w"> </span>unittest<span class="w"> </span>discover<span class="w"> </span>python/tests
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pip install <span class="s2">".[testing]"</span>
|
||||
python -m unittest discover python/tests
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Optional: Install stubs to enable auto completions and type checking from your IDE:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pip<span class="w"> </span>install<span class="w"> </span><span class="s2">".[dev]"</span>
|
||||
python<span class="w"> </span>setup.py<span class="w"> </span>generate_stubs
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pip install <span class="s2">".[dev]"</span>
|
||||
python setup.py generate_stubs
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -735,20 +751,20 @@ python<span class="w"> </span>setup.py<span class="w"> </span>generate_stubs
|
||||
<p>Currently, MLX must be built and installed from source.</p>
|
||||
<p>Similarly to the python library, to build and install the MLX C++ library start
|
||||
by cloning MLX from <a class="reference external" href="https://github.com/ml-explore/mlx">its GitHub repo</a>:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>git<span class="w"> </span>clone<span class="w"> </span>git@github.com:ml-explore/mlx.git<span class="w"> </span>mlx<span class="w"> </span><span class="o">&&</span><span class="w"> </span><span class="nb">cd</span><span class="w"> </span>mlx
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>git clone git@github.com:ml-explore/mlx.git mlx <span class="o">&&</span> <span class="nb">cd</span> mlx
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Create a build directory and run CMake and make:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>mkdir<span class="w"> </span>-p<span class="w"> </span>build<span class="w"> </span><span class="o">&&</span><span class="w"> </span><span class="nb">cd</span><span class="w"> </span>build
|
||||
cmake<span class="w"> </span>..<span class="w"> </span><span class="o">&&</span><span class="w"> </span>make<span class="w"> </span>-j
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>mkdir -p build <span class="o">&&</span> <span class="nb">cd</span> build
|
||||
cmake .. <span class="o">&&</span> make -j
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Run tests with:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>make<span class="w"> </span><span class="nb">test</span>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>make <span class="nb">test</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Install with:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>make<span class="w"> </span>install
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>make install
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Note that the built <code class="docutils literal notranslate"><span class="pre">mlx.metallib</span></code> file should be either at the same
|
||||
@@ -789,12 +805,12 @@ should point to the path to the built metal library.</p>
|
||||
<p>If you have multiple Xcode installations and wish to use
|
||||
a specific one while building, you can do so by adding the
|
||||
following environment variable before building</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="nb">export</span><span class="w"> </span><span class="nv">DEVELOPER_DIR</span><span class="o">=</span><span class="s2">"/path/to/Xcode.app/Contents/Developer/"</span>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="nb">export</span> <span class="nv">DEVELOPER_DIR</span><span class="o">=</span><span class="s2">"/path/to/Xcode.app/Contents/Developer/"</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Further, you can use the following command to find out which
|
||||
macOS SDK will be used</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>xcrun<span class="w"> </span>-sdk<span class="w"> </span>macosx<span class="w"> </span>--show-sdk-version
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>xcrun -sdk macosx --show-sdk-version
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -804,15 +820,29 @@ macOS SDK will be used</p>
|
||||
<section id="metal-not-found">
|
||||
<h4>Metal not found<a class="headerlink" href="#metal-not-found" title="Permalink to this heading">#</a></h4>
|
||||
<p>You see the following error when you try to build:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>error:<span class="w"> </span>unable<span class="w"> </span>to<span class="w"> </span>find<span class="w"> </span>utility<span class="w"> </span><span class="s2">"metal"</span>,<span class="w"> </span>not<span class="w"> </span>a<span class="w"> </span>developer<span class="w"> </span>tool<span class="w"> </span>or<span class="w"> </span><span class="k">in</span><span class="w"> </span>PATH
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>error: unable to find utility <span class="s2">"metal"</span>, not a developer tool or <span class="k">in</span> PATH
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>To fix this, first make sure you have Xcode installed:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>xcode-select<span class="w"> </span>--install
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>xcode-select --install
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Then set the active developer directory:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>sudo<span class="w"> </span>xcode-select<span class="w"> </span>--switch<span class="w"> </span>/Applications/Xcode.app/Contents/Developer
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="x86-shell">
|
||||
<h4>x86 Shell<a class="headerlink" href="#x86-shell" title="Permalink to this heading">#</a></h4>
|
||||
<p id="build-shell">If the ouptut of <code class="docutils literal notranslate"><span class="pre">uname</span> <span class="pre">-p</span></code> is <code class="docutils literal notranslate"><span class="pre">x86</span></code> then your shell is running as x86 via
|
||||
Rosetta instead of natively.</p>
|
||||
<p>To fix this, find the application in Finder (<code class="docutils literal notranslate"><span class="pre">/Applications</span></code> for iTerm,
|
||||
<code class="docutils literal notranslate"><span class="pre">/Applications/Utilities</span></code> for Terminal), right-click, and click “Get Info”.
|
||||
Uncheck “Open using Rosetta”, close the “Get Info” window, and restart your
|
||||
terminal.</p>
|
||||
<p>Verify the terminal is now running natively the following command:</p>
|
||||
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>$ uname -p
|
||||
arm
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -874,6 +904,7 @@ macOS SDK will be used</p>
|
||||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#c-api">C++ API</a></li>
|
||||
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id2">Troubleshooting</a><ul class="nav section-nav flex-column">
|
||||
<li class="toc-h4 nav-item toc-entry"><a class="reference internal nav-link" href="#metal-not-found">Metal not found</a></li>
|
||||
<li class="toc-h4 nav-item toc-entry"><a class="reference internal nav-link" href="#x86-shell">x86 Shell</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
Reference in New Issue
Block a user