blob: d33351a11da32b0a3433f5843ae77070629f2d0d [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 on Ubuntu" />
<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 on Ubuntu" />
<title>Installing MXNet on Ubuntu &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("/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 id="main-nav" class='nav-bar'>
<a class="main-nav-link" href="../install/index.html">Install</a>
<span id="dropdown-menu-position-anchor">
<a href="#" class="main-nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">Gluon <span class="caret"></span></a>
<ul id="package-dropdown-menu" class="dropdown-menu navbar-menu">
<li><a class="main-nav-link" href="../gluon/index.html">About</a></li>
<li><a class="main-nav-link" href="http://gluon.mxnet.io">Tutorials</a></li>
</ul>
</span>
<span id="dropdown-menu-position-anchor">
<a href="#" class="main-nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">API <span class="caret"></span></a>
<ul id="package-dropdown-menu" class="dropdown-menu navbar-menu">
<li><a class="main-nav-link" href="../api/python/index.html">Python</a></li>
<li><a class="main-nav-link" href="../api/c++/index.html">C++</a></li>
<li><a class="main-nav-link" href="../api/clojure/index.html">Clojure</a></li>
<li><a class="main-nav-link" href="../api/julia/index.html">Julia</a></li>
<li><a class="main-nav-link" href="../api/perl/index.html">Perl</a></li>
<li><a class="main-nav-link" href="../api/r/index.html">R</a></li>
<li><a class="main-nav-link" href="../api/scala/index.html">Scala</a></li>
</ul>
</span>
<span id="dropdown-menu-position-anchor-docs">
<a href="#" class="main-nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">Docs <span class="caret"></span></a>
<ul id="package-dropdown-menu-docs" class="dropdown-menu navbar-menu">
<li><a class="main-nav-link" href="../faq/index.html">FAQ</a></li>
<li><a class="main-nav-link" href="../tutorials/index.html">Tutorials</a>
<li><a class="main-nav-link" href="https://github.com/apache/incubator-mxnet/tree/master/example">Examples</a></li>
<li><a class="main-nav-link" href="../architecture/index.html">Architecture</a></li>
<li><a class="main-nav-link" href="../api/python/gluon/model_zoo.html">Model Zoo</a></li>
<li><a class="main-nav-link" href="../api/python/contrib/onnx.html">ONNX</a></li>
</ul>
</span>
<span id="dropdown-menu-position-anchor-community">
<a href="#" class="main-nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">Community <span class="caret"></span></a>
<ul id="package-dropdown-menu-community" class="dropdown-menu navbar-menu">
<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">Github</a></li>
<li><a class="main-nav-link" href="../community/contribute.html">Contribute</a></li>
<li><a class="main-nav-link" href="../community/ecosystem.html">Ecosystem</a></li>
<li><a class="main-nav-link" href="../community/powered_by.html">Powered By</a></li>
</ul>
</span>
</nav>
<script> function getRootPath(){ return "../" } </script>
<div class="burgerIcon dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"></a>
<ul id="burgerMenu" class="dropdown-menu">
<li><a href="../install/index.html">Install</a></li>
<li><a class="main-nav-link" href="../tutorials/index.html">Tutorials</a></li>
<li class="dropdown-submenu dropdown">
<a href="#" tabindex="-1" aria-haspopup="true" role="button" class="dropdown-toggle burger-link" data-toggle="dropdown">Community</a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="http://discuss.mxnet.io">Forum</a></li>
<li><a tabindex="-1" href="https://github.com/apache/incubator-mxnet">Github</a></li>
<li><a tabindex="-1" href="../community/contribute.html">Contribute</a></li>
<li><a tabindex="-1" href="../community/ecosystem.html">Ecosystem</a></li>
<li><a tabindex="-1" href="../community/powered_by.html">Powered By</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="#" tabindex="-1" role="button" aria-haspopup="true" class="dropdown-toggle burger-link" data-toggle="dropdown">API</a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="../api/python/index.html">Python</a>
</li>
<li><a tabindex="-1" href="../api/c++/index.html">C++</a>
</li>
<li><a tabindex="-1" href="../api/clojure/index.html">Clojure</a>
</li>
<li><a tabindex="-1" href="../api/julia/index.html">Julia</a>
</li>
<li><a tabindex="-1" href="../api/perl/index.html">Perl</a>
</li>
<li><a tabindex="-1" href="../api/r/index.html">R</a>
</li>
<li><a tabindex="-1" href="../api/scala/index.html">Scala</a>
</li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="#" tabindex="-1" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle burger-link" data-toggle="dropdown">Docs</a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="../tutorials/index.html">Tutorials</a></li>
<li><a tabindex="-1" href="../faq/index.html">FAQ</a></li>
<li><a tabindex="-1" href="../architecture/index.html">Architecture</a></li>
<li><a tabindex="-1" href="https://github.com/apache/incubator-mxnet/tree/master/example">Examples</a></li>
<li><a tabindex="-1" href="../api/python/gluon/model_zoo.html">Gluon Model Zoo</a></li>
</ul>
</li>
<li><a class="main-nav-link" href="https://github.com/dmlc/mxnet">Github</a></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/contribute.html">Community</a></li>
</ul>
</div>
</div>
<div class="content">
<div class="page-tracker"></div>
<div class="section" id="installing-mxnet-on-ubuntu">
<span id="installing-mxnet-on-ubuntu"></span><h1>Installing MXNet on Ubuntu<a class="headerlink" href="#installing-mxnet-on-ubuntu" title="Permalink to this headline"></a></h1>
<p>The following installation instructions are for installing MXNet on computers running <strong>Ubuntu 16.04</strong>. Support for later versions of Ubuntu is <a class="reference external" href="#contributions">not yet available</a>.</p>
<hr><div class="section" id="contents">
<span id="contents"></span><h2>Contents<a class="headerlink" href="#contents" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><a class="reference external" href="#cuda-dependencies">CUDA Dependencies</a></li>
<li><a class="reference external" href="#quick-installation">Quick Installation</a><ul>
<li><a class="reference external" href="#install-mxnet-for-python">Python</a></li>
<li><a class="reference external" href="#pip-package-availability">pip Packages</a></li>
</ul>
</li>
<li><a class="reference external" href="#build-mxnet-from-source">Build from Source</a></li>
<li><a class="reference external" href="#installing-language-packages-for-mxnet">Installing Language Packages</a><ul>
<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>
<li><a class="reference external" href="#contributions">Contributions</a></li>
<li><a class="reference external" href="#next-steps">Next Steps</a></li>
</ul>
</li>
</ul>
<hr></div>
<div class="section" id="cuda-dependencies">
<span id="cuda-dependencies"></span><h2>CUDA Dependencies<a class="headerlink" href="#cuda-dependencies" title="Permalink to this headline"></a></h2>
<p>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 toolkit</a>. CUDA 9.2 is recommended.</p>
<p>Then download <a class="reference external" href="https://developer.nvidia.com/cudnn">cuDNN 7.1.4</a>.</p>
<p>Unzip the file and change to the cuDNN root directory. Move the header and libraries to your local CUDA Toolkit folder:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> tar xvzf cudnn-9.2-linux-x64-v7.1
sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
sudo ldconfig
</pre></div>
</div>
<hr></div>
<div class="section" id="quick-installation">
<span id="quick-installation"></span><h2>Quick Installation<a class="headerlink" href="#quick-installation" title="Permalink to this headline"></a></h2>
<div class="section" id="install-mxnet-for-python">
<span id="install-mxnet-for-python"></span><h3>Install MXNet for Python<a class="headerlink" href="#install-mxnet-for-python" title="Permalink to this headline"></a></h3>
<div class="section" id="dependencies">
<span id="dependencies"></span><h4>Dependencies<a class="headerlink" href="#dependencies" title="Permalink to this headline"></a></h4>
<p>The following scripts will install Ubuntu 16.04 dependencies for MXNet Python development.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>wget https://raw.githubusercontent.com/apache/incubator-mxnet/master/ci/docker/install/ubuntu_core.sh
wget https://raw.githubusercontent.com/apache/incubator-mxnet/master/ci/docker/install/ubuntu_python.sh
sudo ./ubuntu_core.sh
sudo ./ubuntu_python.sh
</pre></div>
</div>
<p>Using the latest MXNet with CUDA 9.2 package is recommended for the fastest training speeds with MXNet.</p>
<p><strong>Recommended for training:</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>pip install mxnet-cu92
</pre></div>
</div>
<p><strong>Recommended for inference:</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>pip install mxnet-cu92mkl
</pre></div>
</div>
<p>Alternatively, you can use the table below to select the package that suits your purpose.</p>
</div>
<div class="section" id="pip-package-availability">
<span id="pip-package-availability"></span><h4>pip Package Availability<a class="headerlink" href="#pip-package-availability" title="Permalink to this headline"></a></h4>
<p>The following table presents the pip packages that are recommended for each version of MXNet.</p>
<!-- Must find sol'n for both github and website; image in the meantime
--><p><img alt="pip package table" src="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/install/pip-packages.png" /></p>
<p>To install an older version of MXNet with one of the packages in the previous table add <code class="docutils literal"><span class="pre">==</span></code> with the version you require. For example for version 1.1.0 of MXNet with CUDA 8, you would use <code class="docutils literal"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">mxnet-cu80==1.1.0</span></code>.</p>
<hr></div>
</div>
</div>
<div class="section" id="build-mxnet-from-source">
<span id="build-mxnet-from-source"></span><h2>Build MXNet from Source<a class="headerlink" href="#build-mxnet-from-source" title="Permalink to this headline"></a></h2>
<p>You can build MXNet from source, and then you have the option of installing language-specific bindings, such as Scala, Julia, R or Perl. This is a two-step process:</p>
<ol class="simple">
<li>Build the shared library from the MXNet C++ source code.</li>
<li>(optional) Install the supported language-specific packages for MXNet. Be sure to check that section first, as some scripts may be available to handle all of the dependencies, MXNet build, and language bindings for you. Here they are again for quick access:</li>
</ol>
<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>
<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 prior to building MXNet. More information on this is mentioned in the different language package instructions.</p>
<div class="section" id="build-the-shared-library">
<span id="build-the-shared-library"></span><h3>Build the Shared Library<a class="headerlink" href="#build-the-shared-library" title="Permalink to this headline"></a></h3>
<div class="section" id="quick-mxnet-installation">
<span id="quick-mxnet-installation"></span><h4>Quick MXNet Installation<a class="headerlink" href="#quick-mxnet-installation" title="Permalink to this headline"></a></h4>
<p>You can quickly build MXNet with the following script found in the <code class="docutils literal"><span class="pre">/docs/install</span></code> folder:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="nb">cd</span> docs/install
./install_mxnet_ubuntu_python.sh
</pre></div>
</div>
<p>Or you can go through a manual process described next.</p>
</div>
<div class="section" id="manual-mxnet-installation">
<span id="manual-mxnet-installation"></span><h4>Manual MXNet Installation<a class="headerlink" href="#manual-mxnet-installation" title="Permalink to this headline"></a></h4>
<p>On Ubuntu versions 16.04 or later, you need the following dependencies:</p>
<p><strong>Step 1:</strong> Install build tools and git.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> sudo apt-get update
sudo apt-get install -y build-essential git
</pre></div>
</div>
<p><strong>Step 2:</strong> Install OpenBLAS.</p>
<p><em>MXNet</em> uses <a class="reference external" href="https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms">BLAS</a> library for accelerated numerical computations on CPU machine. There are several flavors of BLAS libraries - <a class="reference external" href="http://www.openblas.net/">OpenBLAS</a>, <a class="reference external" href="http://math-atlas.sourceforge.net/">ATLAS</a> and <a class="reference external" href="https://software.intel.com/en-us/intel-mkl">MKL</a>. In this step we install OpenBLAS. You can choose to install ATLAS or MKL.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> sudo apt-get install -y libopenblas-dev
</pre></div>
</div>
<p><strong>Step 3:</strong> Install OpenCV.</p>
<p><em>MXNet</em> uses <a class="reference external" href="http://opencv.org/">OpenCV</a> for efficient image loading and augmentation operations.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> sudo apt-get install -y libopencv-dev
</pre></div>
</div>
<p><strong>Step 4:</strong> Download MXNet sources and build MXNet core shared library.</p>
<p>If building on CPU:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> git clone --recursive https://github.com/apache/incubator-mxnet.git
<span class="nb">cd</span> mxnet
make -j <span class="k">$(</span>nproc<span class="k">)</span> <span class="nv">USE_OPENCV</span><span class="o">=</span><span class="m">1</span> <span class="nv">USE_BLAS</span><span class="o">=</span>openblas
</pre></div>
</div>
<p>If building on GPU (make sure you have installed the <a class="reference external" href="#cuda-dependencies">CUDA dependencies first</a>):</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> git clone --recursive https://github.com/apache/incubator-mxnet.git
<span class="nb">cd</span> mxnet
make -j <span class="k">$(</span>nproc<span class="k">)</span> <span class="nv">USE_OPENCV</span><span class="o">=</span><span class="m">1</span> <span class="nv">USE_BLAS</span><span class="o">=</span>openblas <span class="nv">USE_CUDA</span><span class="o">=</span><span class="m">1</span> <span class="nv">USE_CUDA_PATH</span><span class="o">=</span>/usr/local/cuda <span class="nv">USE_CUDNN</span><span class="o">=</span><span class="m">1</span>
</pre></div>
</div>
<p><em>Note</em> - USE_OPENCV and USE_BLAS are make file flags to set compilation options to use OpenCV and BLAS library. You can explore and use more compilation options in <code class="docutils literal"><span class="pre">make/config.mk</span></code>.</p>
<p>Executing these commands creates a library called <code class="docutils literal"><span class="pre">libmxnet.so</span></code>.</p>
<p>Next, you may optionally install <code class="docutils literal"><span class="pre">graphviz</span></code> library that is used for visualizing network graphs you build on MXNet. You may also install <a class="reference external" href="http://jupyter.readthedocs.io/">Jupyter Notebook</a> which is used for running MXNet tutorials and examples.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span> sudo apt-get install -y python-pip
sudo pip install graphviz
sudo pip install jupyter
</pre></div>
</div>
<hr></div>
</div>
</div>
<div class="section" id="installing-language-packages-for-mxnet">
<span id="installing-language-packages-for-mxnet"></span><h2>Installing Language Packages for MXNet<a class="headerlink" href="#installing-language-packages-for-mxnet" title="Permalink to this headline"></a></h2>
<p>After you have installed the MXNet core library. You may install MXNet interface packages for the programming language of your choice:</p>
<ul class="simple">
<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-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-perl">Perl</a></li>
</ul>
<div class="section" id="install-the-mxnet-package-for-scala">
<span id="install-the-mxnet-package-for-scala"></span><h3>Install the MXNet Package for Scala<a class="headerlink" href="#install-the-mxnet-package-for-scala" title="Permalink to this headline"></a></h3>
<p>To use the MXNet-Scala package, you can acquire the Maven package as a dependency.</p>
<p>Further information is in the <a class="reference external" href="http://mxnet.io/install/scala_setup.html">MXNet-Scala Setup Instructions</a>.</p>
<p>If you use IntelliJ or a similar IDE, you may want to follow the <a class="reference external" href="http://mxnet.io/tutorials/scala/mxnet_scala_on_intellij.html">MXNet-Scala on IntelliJ tutorial</a> instead.</p>
<hr></div>
<div class="section" id="install-the-mxnet-package-for-r">
<span id="install-the-mxnet-package-for-r"></span><h3>Install the MXNet Package for R<a class="headerlink" href="#install-the-mxnet-package-for-r" title="Permalink to this headline"></a></h3>
<p>Building <em>MXNet</em> from source is a 2 step process.</p>
<ol class="simple">
<li>Build the <em>MXNet</em> core shared library, <code class="docutils literal"><span class="pre">libmxnet.so</span></code>, from source.</li>
<li>Build the R bindings.</li>
</ol>
<div class="section" id="quick-mxnet-r-installation">
<span id="quick-mxnet-r-installation"></span><h4>Quick MXNet-R Installation<a class="headerlink" href="#quick-mxnet-r-installation" title="Permalink to this headline"></a></h4>
<p>You can quickly build MXNet-R with the following two scripts found in the <code class="docutils literal"><span class="pre">/docs/install</span></code> folder:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>git clone --recursive https://github.com/apache/incubator-mxnet.git mxnet
<span class="nb">cd</span> mxnet/docs/install
./install_mxnet_ubuntu_python.sh
./install_mxnet_ubuntu_r.sh
</pre></div>
</div>
<p>Or you can go through a manual process described next.</p>
</div>
<div class="section" id="manual-mxnet-r-installation">
<span id="manual-mxnet-r-installation"></span><h4>Manual MXNet-R Installation<a class="headerlink" href="#manual-mxnet-r-installation" title="Permalink to this headline"></a></h4>
<p><strong>Minimum Requirements</strong></p>
<ol class="simple">
<li><a class="reference external" href="https://gcc.gnu.org/gcc-4.8/">GCC 4.8</a> or later to compile C++ 11.</li>
<li><a class="reference external" href="https://www.gnu.org/software/make/">GNU Make</a></li>
</ol>
<p><br/></p>
<p><strong>Build the MXNet core shared library</strong></p>
<p><strong>Step 1</strong> Install build tools and git.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get update
$ sudo apt-get install -y build-essential git
</pre></div>
</div>
<p><strong>Step 2</strong> Install OpenBLAS.</p>
<p><em>MXNet</em> uses <a class="reference external" href="https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms">BLAS</a> and <a class="reference external" href="https://en.wikipedia.org/wiki/LAPACK">LAPACK</a> libraries for accelerated numerical computations on CPU machine. There are several flavors of BLAS/LAPACK libraries - <a class="reference external" href="http://www.openblas.net/">OpenBLAS</a>, <a class="reference external" href="http://math-atlas.sourceforge.net/">ATLAS</a> and <a class="reference external" href="https://software.intel.com/en-us/intel-mkl">MKL</a>. In this step we install OpenBLAS. You can choose to install ATLAS or MKL.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get install -y libopenblas-dev liblapack-dev
</pre></div>
</div>
<p><strong>Step 3</strong> Install OpenCV.</p>
<p><em>MXNet</em> uses <a class="reference external" href="http://opencv.org/">OpenCV</a> for efficient image loading and augmentation operations.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ sudo apt-get install -y libopencv-dev
</pre></div>
</div>
<p><strong>Step 4</strong> Download MXNet sources and build MXNet core shared library. You can clone the repository as described in the following code block, or you may try the <a href="download.html">download links</a> for your desired MXNet version.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ git clone --recursive https://github.com/apache/incubator-mxnet
$ <span class="nb">cd</span> incubator-mxnet
$ make -j <span class="k">$(</span>nproc<span class="k">)</span> <span class="nv">USE_OPENCV</span><span class="o">=</span><span class="m">1</span> <span class="nv">USE_BLAS</span><span class="o">=</span>openblas
</pre></div>
</div>
<p><em>Note</em> - USE_OPENCV and USE_BLAS are make file flags to set compilation options to use OpenCV and BLAS library. You can explore and use more compilation options in <code class="docutils literal"><span class="pre">make/config.mk</span></code>.</p>
<p><br/></p>
<p><strong>Step 5</strong> Make and install the MXNet-R bindings.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>$ make rpkg
</pre></div>
</div>
</div>
<div class="section" id="verify-mxnet-r-installation">
<span id="verify-mxnet-r-installation"></span><h4>Verify MXNet-R Installation<a class="headerlink" href="#verify-mxnet-r-installation" title="Permalink to this headline"></a></h4>
<p>You can verify your MXNet-R installation as follows:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>sudo -i R
</pre></div>
</div>
<p>At the R prompt enter the following:</p>
<div class="highlight-r"><div class="highlight"><pre><span></span><span class="kn">library</span><span class="p">(</span>mxnet<span class="p">)</span>
a <span class="o">&lt;-</span> mx.nd.ones<span class="p">(</span><span class="kt">c</span><span class="p">(</span><span class="m">2</span><span class="p">,</span><span class="m">3</span><span class="p">),</span> ctx <span class="o">=</span> mx.cpu<span class="p">())</span>
b <span class="o">&lt;-</span> a <span class="o">*</span> <span class="m">2</span> <span class="o">+</span> <span class="m">1</span>
b
</pre></div>
</div>
<p>You should see the following output:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span> <span class="p">[,</span><span class="mi">1</span><span class="p">]</span> <span class="p">[,</span><span class="mi">2</span><span class="p">]</span> <span class="p">[,</span><span class="mi">3</span><span class="p">]</span>
<span class="p">[</span><span class="mi">1</span><span class="p">,]</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">3</span>
<span class="p">[</span><span class="mi">2</span><span class="p">,]</span> <span class="mi">3</span> <span class="mi">3</span> <span class="mi">3</span>
<span class="o">&gt;</span> <span class="n">quit</span><span class="p">()</span>
</pre></div>
</div>
<hr></div>
</div>
<div class="section" id="install-the-mxnet-package-for-julia">
<span id="install-the-mxnet-package-for-julia"></span><h3>Install the MXNet Package for Julia<a class="headerlink" href="#install-the-mxnet-package-for-julia" title="Permalink to this headline"></a></h3>
<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>
<hr></div>
</div>
<div class="section" id="install-the-mxnet-package-for-scala">
<span id="id1"></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>To use the MXNet-Scala package, you can acquire the Maven package as a dependency.</p>
<p>Further information is in the <a class="reference internal" href="scala_setup.html"><span class="doc">MXNet-Scala Setup Instructions</span></a>.</p>
<p>If you use IntelliJ or a similar IDE, you may want to follow the <a class="reference internal" href="../tutorials/scala/mxnet_scala_on_intellij.html"><span class="doc">MXNet-Scala on IntelliJ tutorial</span></a> instead.</p>
<div class="section" id="install-the-mxnet-package-for-perl">
<span id="install-the-mxnet-package-for-perl"></span><h3>Install the MXNet Package for Perl<a class="headerlink" href="#install-the-mxnet-package-for-perl" title="Permalink to this headline"></a></h3>
<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> sudo apt-get install libmouse-perl pdl cpanminus swig libgraphviz-perl
cpanm -q -L <span class="s2">&quot;</span><span class="si">${</span><span class="nv">HOME</span><span class="si">}</span><span class="s2">/perl5&quot;</span> Function::Parameters Hash::Ordered PDL::CCS
<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">LD_LIBRARY_PATH</span><span class="o">=</span><span class="si">${</span><span class="nv">MXNET_HOME</span><span class="si">}</span>/lib
<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
<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
<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>
<hr></div>
</div>
<div class="section" id="contributions">
<span id="contributions"></span><h2>Contributions<a class="headerlink" href="#contributions" title="Permalink to this headline"></a></h2>
<p>You are more than welcome to contribute easy installation scripts for other operating systems and programming languages. See the <a class="reference external" href="http://mxnet.io/community/contribute.html">community contributions page</a> for further information.</p>
</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="http://mxnet.io/tutorials/index.html">Tutorials</a></li>
<li class="toctree-l1"><a class="reference external" href="http://mxnet.io/faq/index.html">How To</a></li>
<li class="toctree-l1"><a class="reference external" href="http://mxnet.io/architecture/index.html">Architecture</a></li>
</ul>
</div>
<p><link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous"></p>
</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 on Ubuntu</a><ul>
<li><a class="reference internal" href="#contents">Contents</a></li>
<li><a class="reference internal" href="#cuda-dependencies">CUDA Dependencies</a></li>
<li><a class="reference internal" href="#quick-installation">Quick Installation</a><ul>
<li><a class="reference internal" href="#install-mxnet-for-python">Install MXNet for Python</a><ul>
<li><a class="reference internal" href="#dependencies">Dependencies</a></li>
<li><a class="reference internal" href="#pip-package-availability">pip Package Availability</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#build-mxnet-from-source">Build MXNet from Source</a><ul>
<li><a class="reference internal" href="#build-the-shared-library">Build the Shared Library</a><ul>
<li><a class="reference internal" href="#quick-mxnet-installation">Quick MXNet Installation</a></li>
<li><a class="reference internal" href="#manual-mxnet-installation">Manual MXNet Installation</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#installing-language-packages-for-mxnet">Installing Language Packages for MXNet</a><ul>
<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-r">Install the MXNet Package for R</a><ul>
<li><a class="reference internal" href="#quick-mxnet-r-installation">Quick MXNet-R Installation</a></li>
<li><a class="reference internal" href="#manual-mxnet-r-installation">Manual MXNet-R Installation</a></li>
<li><a class="reference internal" href="#verify-mxnet-r-installation">Verify MXNet-R Installation</a></li>
</ul>
</li>
<li><a class="reference internal" href="#install-the-mxnet-package-for-julia">Install the MXNet Package for Julia</a></li>
</ul>
</li>
<li><a class="reference internal" href="#install-the-mxnet-package-for-scala">Install the MXNet Package for Scala</a><ul>
<li><a class="reference internal" href="#install-the-mxnet-package-for-perl">Install the MXNet Package for Perl</a></li>
</ul>
</li>
<li><a class="reference internal" href="#contributions">Contributions</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">
$('body').ready(function () {
$('body').css('visibility', 'visible');
});
</script>
</body>
</html>