blob: 23d949441c347dd03fceecb57dad9428aecc509c [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content="Installing MXNet froum source on OS X (Mac)" />
<meta property="og:image" content="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/og-logo.png" />
<meta property="og:image:secure_url" content="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/og-logo.png" />
<meta property="og:description" content="Installing MXNet froum source on OS X (Mac)" />
<title>Installing MXNet froum source on OS X (Mac) &mdash; mxnet documentation</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="../_static/basic.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/mxnet.css" type="text/css">
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/searchtools_custom.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/selectlang.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript"> jQuery(function() { Search.loadIndex("/versions/1.0.0/searchindex.js"); Search.init();}); </script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new
Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-96378503-1', 'auto');
ga('send', 'pageview');
</script>
<!-- -->
<!-- <script type="text/javascript" src="../_static/jquery.js"></script> -->
<!-- -->
<!-- <script type="text/javascript" src="../_static/underscore.js"></script> -->
<!-- -->
<!-- <script type="text/javascript" src="../_static/doctools.js"></script> -->
<!-- -->
<!-- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> -->
<!-- -->
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="icon" type="image/png" href="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-icon.png">
</head>
<body role="document" background="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-background-compressed.jpeg">
<div class='content-block'><div class="navbar navbar-fixed-top">
<div class="container" id="navContainer">
<div id="header-inner" class="innder">
<h1 id="logo-wrap">
<a href="../" id="logo"><img src="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet_logo.png"></a>
</h1>
<nav class="nav-bar" id="main-nav">
<a class="main-nav-link" href="/versions/1.0.0/install/index.html">Install</a>
<span id="dropdown-menu-position-anchor">
<a aria-expanded="true" aria-haspopup="true" class="main-nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">Gluon <span class="caret"></span></a>
<ul class="dropdown-menu navbar-menu" id="package-dropdown-menu">
<li><a class="main-nav-link" href="/versions/1.0.0/tutorials/gluon/gluon.html">About</a></li>
<li><a class="main-nav-link" href="https://www.d2l.ai/">Dive into Deep Learning</a></li>
<li><a class="main-nav-link" href="https://gluon-cv.mxnet.io">GluonCV Toolkit</a></li>
<li><a class="main-nav-link" href="https://gluon-nlp.mxnet.io/">GluonNLP Toolkit</a></li>
</ul>
</span>
<span id="dropdown-menu-position-anchor">
<a aria-expanded="true" aria-haspopup="true" class="main-nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">API <span class="caret"></span></a>
<ul class="dropdown-menu navbar-menu" id="package-dropdown-menu">
<li><a class="main-nav-link" href="/versions/1.0.0/api/python/index.html">Python</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/api/c++/index.html">C++</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/api/julia/index.html">Julia</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/api/perl/index.html">Perl</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/api/r/index.html">R</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/api/scala/index.html">Scala</a></li>
</ul>
</span>
<span id="dropdown-menu-position-anchor-docs">
<a aria-expanded="true" aria-haspopup="true" class="main-nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">Docs <span class="caret"></span></a>
<ul class="dropdown-menu navbar-menu" id="package-dropdown-menu-docs">
<li><a class="main-nav-link" href="/versions/1.0.0/faq/index.html">FAQ</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/tutorials/index.html">Tutorials</a>
<li><a class="main-nav-link" href="https://github.com/apache/incubator-mxnet/tree/v1.0.0/example">Examples</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/architecture/index.html">Architecture</a></li>
<li><a class="main-nav-link" href="https://cwiki.apache.org/confluence/display/MXNET/Apache+MXNet+Home">Developer Wiki</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/model_zoo/index.html">Model Zoo</a></li>
<li><a class="main-nav-link" href="https://github.com/onnx/onnx-mxnet">ONNX</a></li>
</li></ul>
</span>
<span id="dropdown-menu-position-anchor-community">
<a aria-expanded="true" aria-haspopup="true" class="main-nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">Community <span class="caret"></span></a>
<ul class="dropdown-menu navbar-menu" id="package-dropdown-menu-community">
<li><a class="main-nav-link" href="http://discuss.mxnet.io">Forum</a></li>
<li><a class="main-nav-link" href="https://github.com/apache/incubator-mxnet/tree/v1.0.0">Github</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/community/contribute.html">Contribute</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/community/powered_by.html">Powered By</a></li>
</ul>
</span>
<span id="dropdown-menu-position-anchor-version" style="position: relative"><a href="#" class="main-nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">1.0.0<span class="caret"></span></a><ul id="package-dropdown-menu" class="dropdown-menu"><li><a href="/">master</a></li><li><a href="/versions/1.7.0/">1.7.0</a></li><li><a href=/versions/1.6.0/>1.6.0</a></li><li><a href=/versions/1.5.0/>1.5.0</a></li><li><a href=/versions/1.4.1/>1.4.1</a></li><li><a href=/versions/1.3.1/>1.3.1</a></li><li><a href=/versions/1.2.1/>1.2.1</a></li><li><a href=/versions/1.1.0/>1.1.0</a></li><li><a href=/versions/1.0.0/>1.0.0</a></li><li><a href=/versions/0.12.1/>0.12.1</a></li><li><a href=/versions/0.11.0/>0.11.0</a></li></ul></span></nav>
<script> function getRootPath(){ return "../" } </script>
<div class="burgerIcon dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button"></a>
<ul class="dropdown-menu" id="burgerMenu">
<li><a href="/versions/1.0.0/install/index.html">Install</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/tutorials/index.html">Tutorials</a></li>
<li class="dropdown-submenu dropdown">
<a aria-expanded="true" aria-haspopup="true" class="dropdown-toggle burger-link" data-toggle="dropdown" href="#" tabindex="-1">Gluon</a>
<ul class="dropdown-menu navbar-menu" id="package-dropdown-menu">
<li><a class="main-nav-link" href="/versions/1.0.0/tutorials/gluon/gluon.html">About</a></li>
<li><a class="main-nav-link" href="http://gluon.mxnet.io">The Straight Dope (Tutorials)</a></li>
<li><a class="main-nav-link" href="https://gluon-cv.mxnet.io">GluonCV Toolkit</a></li>
<li><a class="main-nav-link" href="https://gluon-nlp.mxnet.io/">GluonNLP Toolkit</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a aria-expanded="true" aria-haspopup="true" class="dropdown-toggle burger-link" data-toggle="dropdown" href="#" tabindex="-1">API</a>
<ul class="dropdown-menu">
<li><a class="main-nav-link" href="/versions/1.0.0/api/python/index.html">Python</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/api/c++/index.html">C++</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/api/julia/index.html">Julia</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/api/perl/index.html">Perl</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/api/r/index.html">R</a></li>
<li><a class="main-nav-link" href="/versions/1.0.0/api/scala/index.html">Scala</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a aria-expanded="true" aria-haspopup="true" class="dropdown-toggle burger-link" data-toggle="dropdown" href="#" tabindex="-1">Docs</a>
<ul class="dropdown-menu">
<li><a href="/versions/1.0.0/faq/index.html" tabindex="-1">FAQ</a></li>
<li><a href="/versions/1.0.0/tutorials/index.html" tabindex="-1">Tutorials</a></li>
<li><a href="https://github.com/apache/incubator-mxnet/tree/v1.0.0/example" tabindex="-1">Examples</a></li>
<li><a href="/versions/1.0.0/architecture/index.html" tabindex="-1">Architecture</a></li>
<li><a href="https://cwiki.apache.org/confluence/display/MXNET/Apache+MXNet+Home" tabindex="-1">Developer Wiki</a></li>
<li><a href="/versions/1.0.0/model_zoo/index.html" tabindex="-1">Gluon Model Zoo</a></li>
<li><a href="https://github.com/onnx/onnx-mxnet" tabindex="-1">ONNX</a></li>
</ul>
</li>
<li class="dropdown-submenu dropdown">
<a aria-haspopup="true" class="dropdown-toggle burger-link" data-toggle="dropdown" href="#" role="button" tabindex="-1">Community</a>
<ul class="dropdown-menu">
<li><a href="http://discuss.mxnet.io" tabindex="-1">Forum</a></li>
<li><a href="https://github.com/apache/incubator-mxnet/tree/v1.0.0" tabindex="-1">Github</a></li>
<li><a href="/versions/1.0.0/community/contribute.html" tabindex="-1">Contribute</a></li>
<li><a href="/versions/1.0.0/community/powered_by.html" tabindex="-1">Powered By</a></li>
</ul>
</li>
<li id="dropdown-menu-position-anchor-version-mobile" class="dropdown-submenu" style="position: relative"><a href="#" tabindex="-1">1.0.0</a><ul class="dropdown-menu"><li><a tabindex="-1" href=/>master</a></li><li><a tabindex="-1" href=/versions/1.6.0/>1.6.0</a></li><li><a tabindex="-1" href=/versions/1.5.0/>1.5.0</a></li><li><a tabindex="-1" href=/versions/1.4.1/>1.4.1</a></li><li><a tabindex="-1" href=/versions/1.3.1/>1.3.1</a></li><li><a tabindex="-1" href=/versions/1.2.1/>1.2.1</a></li><li><a tabindex="-1" href=/versions/1.1.0/>1.1.0</a></li><li><a tabindex="-1" href=/versions/1.0.0/>1.0.0</a></li><li><a tabindex="-1" href=/versions/0.12.1/>0.12.1</a></li><li><a tabindex="-1" href=/versions/0.11.0/>0.11.0</a></li></ul></li></ul>
</div>
<div class="plusIcon dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a>
<ul id="plusMenu" class="dropdown-menu dropdown-menu-right"></ul>
</div>
<div id="search-input-wrap">
<form class="" role="search" action="../search.html" method="get" autocomplete="off">
<div class="form-group inner-addon left-addon">
<i class="glyphicon glyphicon-search"></i>
<input type="text" name="q" class="form-control" placeholder="Search">
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<div id="search-preview"></div>
</div>
<div id='searchIcon'>
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
</div>
<!-- <div id="lang-select-wrap"> -->
<!-- <label id="lang-select-label"> -->
<!-- <\!-- <i class="fa fa-globe"></i> -\-> -->
<!-- <span></span> -->
<!-- </label> -->
<!-- <select id="lang-select"> -->
<!-- <option value="en">Eng</option> -->
<!-- <option value="zh">中文</option> -->
<!-- </select> -->
<!-- </div> -->
<!-- <a id="mobile-nav-toggle">
<span class="mobile-nav-toggle-bar"></span>
<span class="mobile-nav-toggle-bar"></span>
<span class="mobile-nav-toggle-bar"></span>
</a> -->
</div>
</div>
</div>
<script type="text/javascript">
$('body').css('background', 'white');
</script>
<div class="container">
<div class="row">
<div class="sphinxsidebar leftsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../api/python/index.html">Python Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../api/r/index.html">R Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../api/julia/index.html">Julia Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../api/c++/index.html">C++ Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../api/scala/index.html">Scala Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../api/perl/index.html">Perl Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../faq/index.html">HowTo Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../architecture/index.html">System Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">Tutorials</a></li>
<li class="toctree-l1"><a class="reference internal" href="../community/index.html">Community</a></li>
</ul>
</div>
</div>
<div class="content">
<div class="page-tracker"></div>
<div class="section" id="installing-mxnet-froum-source-on-os-x-mac">
<span id="installing-mxnet-froum-source-on-os-x-mac"></span><h1>Installing MXNet froum source on OS X (Mac)<a class="headerlink" href="#installing-mxnet-froum-source-on-os-x-mac" title="Permalink to this headline"></a></h1>
<p><strong>NOTE:</strong> For prebuild MXNet with Python installation, please refer to the <a class="reference external" href="/versions/1.0.0/install/index.html">new install guide</a>.</p>
<p>Installing MXNet is a two-step process:</p>
<ol class="simple">
<li>Build the shared library from the MXNet C++ source code.</li>
<li>Install the supported language-specific packages for MXNet.</li>
</ol>
<p><strong>Note:</strong> To change the compilation options for your build, edit the <code class="docutils literal"><span class="pre">make/config.mk</span></code> file and submit a build request with the <code class="docutils literal"><span class="pre">make</span></code> command.</p>
<div class="section" id="prepare-environment-for-gpu-installation">
<span id="prepare-environment-for-gpu-installation"></span><h2>Prepare Environment for GPU Installation<a class="headerlink" href="#prepare-environment-for-gpu-installation" title="Permalink to this headline"></a></h2>
<p>This section is optional. Skip to next section if you don&#8217;t plan to use GPUs. If you plan to build with GPU, you need to set up the environment for CUDA and cuDNN.</p>
<p>First, download and install <a class="reference external" href="https://developer.nvidia.com/cuda-toolkit">CUDA 8 toolkit</a>.</p>
<p>Once you have the CUDA Toolkit installed you will need to set up the required environment variables by adding the following to your ~/.bash_profile file:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> <span class="nb">export</span> <span class="nv">CUDA_HOME</span><span class="o">=</span>/usr/local/cuda
<span class="nb">export</span> <span class="nv">DYLD_LIBRARY_PATH</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$CUDA_HOME</span><span class="s2">/lib:</span><span class="nv">$DYLD_LIBRARY_PATH</span><span class="s2">&quot;</span>
<span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$CUDA_HOME</span><span class="s2">/bin:</span><span class="nv">$PATH</span><span class="s2">&quot;</span>
</pre></div>
</div>
<p>Reload ~/.bash_profile file and install dependencies:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> . ~/.bash_profile
brew install coreutils
brew tap caskroom/cask
</pre></div>
</div>
<p>Then download <a class="reference external" href="https://developer.nvidia.com/cudnn">cuDNN 5</a>.</p>
<p>Unzip the file and change to the cudnn root directory. Move the header files and libraries to your local CUDA Toolkit folder:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> $ sudo mv include/cudnn.h /Developer/NVIDIA/CUDA-8.0/include/
$ sudo mv lib/libcudnn* /Developer/NVIDIA/CUDA-8.0/lib
$ sudo ln -s /Developer/NVIDIA/CUDA-8.0/lib/libcudnn* /usr/local/cuda/lib/
</pre></div>
</div>
<p>Now we can start to build MXNet.</p>
</div>
<div class="section" id="build-the-shared-library">
<span id="build-the-shared-library"></span><h2>Build the Shared Library<a class="headerlink" href="#build-the-shared-library" title="Permalink to this headline"></a></h2>
<div class="section" id="install-mxnet-dependencies">
<span id="install-mxnet-dependencies"></span><h3>Install MXNet dependencies<a class="headerlink" href="#install-mxnet-dependencies" title="Permalink to this headline"></a></h3>
<p>Install the dependencies, required for MXNet, with the following commands:</p>
<ul class="simple">
<li><a class="reference external" href="http://brew.sh/">Homebrew</a></li>
<li>OpenBLAS and homebrew/science (for linear algebraic operations)</li>
<li>OpenCV (for computer vision operations)</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span> <span class="c1"># Paste this command in Mac terminal to install Homebrew</span>
/usr/bin/ruby -e <span class="s2">&quot;</span><span class="k">$(</span>curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install<span class="k">)</span><span class="s2">&quot;</span>
<span class="c1"># Insert the Homebrew directory at the top of your PATH environment variable</span>
<span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span>/usr/local/bin:/usr/local/sbin:<span class="nv">$PATH</span>
</pre></div>
</div>
<div class="highlight-bash"><div class="highlight"><pre><span></span> brew update
brew install pkg-config
brew install graphviz
brew install openblas
brew tap homebrew/science
brew install opencv
<span class="c1"># For getting pip</span>
brew install python
<span class="c1"># For visualization of network graphs</span>
pip install graphviz
<span class="c1"># Jupyter notebook</span>
pip install jupyter
</pre></div>
</div>
</div>
<div class="section" id="build-mxnet-shared-library">
<span id="build-mxnet-shared-library"></span><h3>Build MXNet Shared Library<a class="headerlink" href="#build-mxnet-shared-library" title="Permalink to this headline"></a></h3>
<p>After you have installed the dependencies, pull the MXNet source code from Git and build MXNet to produce an MXNet library called <code class="docutils literal"><span class="pre">libmxnet.so</span></code>.</p>
<p>The file called <code class="docutils literal"><span class="pre">osx.mk</span></code> has the configuration required for building MXNet on OS X. First copy <code class="docutils literal"><span class="pre">make/osx.mk</span></code> into <code class="docutils literal"><span class="pre">config.mk</span></code>, which is used by the <code class="docutils literal"><span class="pre">make</span></code> command:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> git clone --recursive https://github.com/dmlc/mxnet ~/mxnet
<span class="nb">cd</span> ~/mxnet
cp make/osx.mk ./config.mk
<span class="nb">echo</span> <span class="s2">&quot;USE_BLAS = openblas&quot;</span> &gt;&gt; ./config.mk
<span class="nb">echo</span> <span class="s2">&quot;ADD_CFLAGS += -I/usr/local/opt/openblas/include&quot;</span> &gt;&gt; ./config.mk
<span class="nb">echo</span> <span class="s2">&quot;ADD_LDFLAGS += -L/usr/local/opt/openblas/lib&quot;</span> &gt;&gt; ./config.mk
<span class="nb">echo</span> <span class="s2">&quot;ADD_LDFLAGS += -L/usr/local/lib/graphviz/&quot;</span> &gt;&gt; ./config.mk
make -j<span class="k">$(</span>sysctl -n hw.ncpu<span class="k">)</span>
</pre></div>
</div>
<p>If building with <code class="docutils literal"><span class="pre">GPU</span></code> support, add the following configuration to config.mk and build:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> <span class="nb">echo</span> <span class="s2">&quot;USE_CUDA = 1&quot;</span> &gt;&gt; ./config.mk
<span class="nb">echo</span> <span class="s2">&quot;USE_CUDA_PATH = /usr/local/cuda&quot;</span> &gt;&gt; ./config.mk
<span class="nb">echo</span> <span class="s2">&quot;USE_CUDNN = 1&quot;</span> &gt;&gt; ./config.mk
make
</pre></div>
</div>
<p><strong>Note:</strong> To change build parameters, edit <code class="docutils literal"><span class="pre">config.mk</span></code>.</p>
<p><p> </p>
</p>
<p>We have installed MXNet core library. Next, we will install MXNet interface package for the programming language of your choice:</p>
<ul class="simple">
<li><a class="reference external" href="#install-the-mxnet-package-for-r">R</a></li>
<li><a class="reference external" href="#install-the-mxnet-package-for-julia">Julia</a></li>
<li><a class="reference external" href="#install-the-mxnet-package-for-scala">Scala</a></li>
<li><a class="reference external" href="#install-the-mxnet-package-for-perl">Perl</a></li>
</ul>
</div>
</div>
<div class="section" id="install-the-mxnet-package-for-r">
<span id="install-the-mxnet-package-for-r"></span><h2>Install the MXNet Package for R<a class="headerlink" href="#install-the-mxnet-package-for-r" title="Permalink to this headline"></a></h2>
<p>You have 2 options:</p>
<ol class="simple">
<li>Building MXNet with the Prebuilt Binary Package</li>
<li>Building MXNet from Source Code</li>
</ol>
<div class="section" id="building-mxnet-with-the-prebuilt-binary-package">
<span id="building-mxnet-with-the-prebuilt-binary-package"></span><h3>Building MXNet with the Prebuilt Binary Package<a class="headerlink" href="#building-mxnet-with-the-prebuilt-binary-package" title="Permalink to this headline"></a></h3>
<p>For OS X (Mac) users, MXNet provides a prebuilt binary package for CPUs. The prebuilt package is updated weekly. You can install the package directly in the R console using the following commands:</p>
<div class="highlight-r"><div class="highlight"><pre><span></span> <span class="n">cran</span> <span class="o">&lt;-</span> <span class="nf">getOption</span><span class="p">(</span><span class="s">&quot;repos&quot;</span><span class="p">)</span>
<span class="n">cran[</span><span class="s">&quot;dmlc&quot;</span><span class="n">]</span> <span class="o">&lt;-</span> <span class="s">&quot;https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/&quot;</span>
<span class="nf">options</span><span class="p">(</span><span class="n">repos</span> <span class="o">=</span> <span class="n">cran</span><span class="p">)</span>
<span class="nf">install.packages</span><span class="p">(</span><span class="s">&quot;mxnet&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="building-mxnet-from-source-code">
<span id="building-mxnet-from-source-code"></span><h3>Building MXNet from Source Code<a class="headerlink" href="#building-mxnet-from-source-code" title="Permalink to this headline"></a></h3>
<p>Run the following commands to install the MXNet dependencies and build the MXNet R package.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> Rscript -e <span class="s2">&quot;install.packages(&#39;devtools&#39;, repo = &#39;https://cran.rstudio.com&#39;)&quot;</span>
</pre></div>
</div>
<div class="highlight-bash"><div class="highlight"><pre><span></span> <span class="nb">cd</span> R-package
Rscript -e <span class="s2">&quot;library(devtools); library(methods); options(repos=c(CRAN=&#39;https://cran.rstudio.com&#39;)); install_deps(dependencies = TRUE)&quot;</span>
<span class="nb">cd</span> ..
make rpkg
</pre></div>
</div>
<p><strong>Note:</strong> R-package is a folder in the MXNet source.</p>
<p>These commands create the MXNet R package as a tar.gz file that you can install as an R package. To install the R package, run the following command, use your MXNet version number:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> R CMD INSTALL mxnet_current_r.tar.gz
</pre></div>
</div>
</div>
</div>
<div class="section" id="install-the-mxnet-package-for-julia">
<span id="install-the-mxnet-package-for-julia"></span><h2>Install the MXNet Package for Julia<a class="headerlink" href="#install-the-mxnet-package-for-julia" title="Permalink to this headline"></a></h2>
<p>The MXNet package for Julia is hosted in a separate repository, MXNet.jl, which is available on <a class="reference external" href="https://github.com/dmlc/MXNet.jl">GitHub</a>. To use Julia binding it with an existing libmxnet installation, set the <code class="docutils literal"><span class="pre">MXNET_HOME</span></code> environment variable by running the following command:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> <span class="nb">export</span> <span class="nv">MXNET_HOME</span><span class="o">=</span>/&lt;path to&gt;/libmxnet
</pre></div>
</div>
<p>The path to the existing libmxnet installation should be the root directory of libmxnet. In other words, you should be able to find the <code class="docutils literal"><span class="pre">libmxnet.so</span></code> file at <code class="docutils literal"><span class="pre">$MXNET_HOME/lib</span></code>. For example, if the root directory of libmxnet is <code class="docutils literal"><span class="pre">~</span></code>, you would run the following command:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> <span class="nb">export</span> <span class="nv">MXNET_HOME</span><span class="o">=</span>/~/libmxnet
</pre></div>
</div>
<p>You might want to add this command to your <code class="docutils literal"><span class="pre">~/.bashrc</span></code> file. If you do, you can install the Julia package in the Julia console using the following command:</p>
<div class="highlight-julia"><div class="highlight"><pre><span></span> <span class="n">Pkg</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&quot;MXNet&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>For more details about installing and using MXNet with Julia, see the <a class="reference external" href="http://dmlc.ml/MXNet.jl/latest/user-guide/install/">MXNet Julia documentation</a>.</p>
</div>
<div class="section" id="install-the-mxnet-package-for-scala">
<span id="install-the-mxnet-package-for-scala"></span><h2>Install the MXNet Package for Scala<a class="headerlink" href="#install-the-mxnet-package-for-scala" title="Permalink to this headline"></a></h2>
<p>Before you build MXNet for Scala from source code, you must complete <a class="reference external" href="#build-the-shared-library">building the shared library</a>. After you build the shared library, run the following command from the MXNet source root directory to build the MXNet Scala package:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> make scalapkg
</pre></div>
</div>
<p>This command creates the JAR files for the assembly, core, and example modules. It also creates the native library in the <code class="docutils literal"><span class="pre">native/{your-architecture}/target</span> <span class="pre">directory</span></code>, which you can use to cooperate with the core module.</p>
<p>To install the MXNet Scala package into your local Maven repository, run the following command from the MXNet source root directory:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> make scalainstall
</pre></div>
</div>
</div>
<div class="section" id="install-the-mxnet-package-for-perl">
<span id="install-the-mxnet-package-for-perl"></span><h2>Install the MXNet Package for Perl<a class="headerlink" href="#install-the-mxnet-package-for-perl" title="Permalink to this headline"></a></h2>
<p>Before you build MXNet for Perl from source code, you must complete <a class="reference external" href="#build-the-shared-library">building the shared library</a>.
After you build the shared library, run the following command from the MXNet source root directory to build the MXNet Perl package:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> brew install swig
sudo sh -c <span class="s1">&#39;curl -L https://cpanmin.us | perl - App::cpanminus&#39;</span>
sudo cpanm -q -n PDL Mouse Function::Parameters Hash::Ordered
<span class="nv">MXNET_HOME</span><span class="o">=</span><span class="si">${</span><span class="nv">PWD</span><span class="si">}</span>
<span class="nb">export</span> <span class="nv">PERL5LIB</span><span class="o">=</span><span class="si">${</span><span class="nv">HOME</span><span class="si">}</span>/perl5/lib/perl5
<span class="nb">cd</span> <span class="si">${</span><span class="nv">MXNET_HOME</span><span class="si">}</span>/perl-package/AI-MXNetCAPI/
perl Makefile.PL <span class="nv">INSTALL_BASE</span><span class="o">=</span><span class="si">${</span><span class="nv">HOME</span><span class="si">}</span>/perl5
make
install_name_tool -change lib/libmxnet.so <span class="se">\</span>
<span class="si">${</span><span class="nv">MXNET_HOME</span><span class="si">}</span>/lib/libmxnet.so <span class="se">\</span>
blib/arch/auto/AI/MXNetCAPI/MXNetCAPI.bundle
make install
<span class="nb">cd</span> <span class="si">${</span><span class="nv">MXNET_HOME</span><span class="si">}</span>/perl-package/AI-NNVMCAPI/
perl Makefile.PL <span class="nv">INSTALL_BASE</span><span class="o">=</span><span class="si">${</span><span class="nv">HOME</span><span class="si">}</span>/perl5
make
install_name_tool -change lib/libmxnet.so <span class="se">\</span>
<span class="si">${</span><span class="nv">MXNET_HOME</span><span class="si">}</span>/lib/libmxnet.so <span class="se">\</span>
blib/arch/auto/AI/NNVMCAPI/NNVMCAPI.bundle
make install
<span class="nb">cd</span> <span class="si">${</span><span class="nv">MXNET_HOME</span><span class="si">}</span>/perl-package/AI-MXNet/
perl Makefile.PL <span class="nv">INSTALL_BASE</span><span class="o">=</span><span class="si">${</span><span class="nv">HOME</span><span class="si">}</span>/perl5
make install
</pre></div>
</div>
</div>
<div class="section" id="next-steps">
<span id="next-steps"></span><h2>Next Steps<a class="headerlink" href="#next-steps" title="Permalink to this headline"></a></h2>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference external" href="/versions/1.0.0/tutorials/index.html">Tutorials</a></li>
<li class="toctree-l1"><a class="reference external" href="/versions/1.0.0/how_to/index.html">How To</a></li>
<li class="toctree-l1"><a class="reference external" href="/versions/1.0.0/architecture/index.html">Architecture</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar rightsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Installing MXNet froum source on OS X (Mac)</a><ul>
<li><a class="reference internal" href="#prepare-environment-for-gpu-installation">Prepare Environment for GPU Installation</a></li>
<li><a class="reference internal" href="#build-the-shared-library">Build the Shared Library</a><ul>
<li><a class="reference internal" href="#install-mxnet-dependencies">Install MXNet dependencies</a></li>
<li><a class="reference internal" href="#build-mxnet-shared-library">Build MXNet Shared Library</a></li>
</ul>
</li>
<li><a class="reference internal" href="#install-the-mxnet-package-for-r">Install the MXNet Package for R</a><ul>
<li><a class="reference internal" href="#building-mxnet-with-the-prebuilt-binary-package">Building MXNet with the Prebuilt Binary Package</a></li>
<li><a class="reference internal" href="#building-mxnet-from-source-code">Building MXNet from Source Code</a></li>
</ul>
</li>
<li><a class="reference internal" href="#install-the-mxnet-package-for-julia">Install the MXNet Package for Julia</a></li>
<li><a class="reference internal" href="#install-the-mxnet-package-for-scala">Install the MXNet Package for Scala</a></li>
<li><a class="reference internal" href="#install-the-mxnet-package-for-perl">Install the MXNet Package for Perl</a></li>
<li><a class="reference internal" href="#next-steps">Next Steps</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div><div class="footer">
<div class="section-disclaimer">
<div class="container">
<div>
<img src="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/apache_incubator_logo.png" height=60>
<p>
Apache MXNet is an effort undergoing incubation at The Apache Software Foundation (ASF), <strong>sponsored by the <i>Apache Incubator</i></strong>. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
</p>
<p>
"Copyright © 2017-2018, The Apache Software Foundation
Apache MXNet, MXNet, Apache, the Apache feather, and the Apache MXNet project logo are either registered trademarks or trademarks of the Apache Software Foundation."
</p>
</div>
</div>
</div>
</div> <!-- pagename != index -->
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script type="text/javascript" src="../_static/js/sidebar.js"></script>
<script type="text/javascript" src="../_static/js/search.js"></script>
<script type="text/javascript" src="../_static/js/navbar.js"></script>
<script type="text/javascript" src="../_static/js/clipboard.min.js"></script>
<script type="text/javascript" src="../_static/js/copycode.js"></script>
<script type="text/javascript" src="../_static/js/page.js"></script>
<script type="text/javascript" src="../_static/js/docversion.js"></script>
<script type="text/javascript">
$('body').ready(function () {
$('body').css('visibility', 'visible');
});
</script>
</body>
</html>