blob: 110fb7599cf1b990b6bd020a53c6140f12041154 [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="Build MXNet from Source" />
<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="Build MXNet from Source" />
<title>Build MXNet from Source &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.4.1/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="up" title="Installing MXNet" href="index.html" />
<link rel="next" title="Build the C++ package" href="c_plus_plus.html" />
<link rel="prev" title="&lt;no title&gt;" href="amazonlinux_setup.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.4.1/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.4.1/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.4.1/api/python/index.html">Python</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/api/c++/index.html">C++</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/api/clojure/index.html">Clojure</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/api/java/index.html">Java</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/api/julia/index.html">Julia</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/api/perl/index.html">Perl</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/api/r/index.html">R</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/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.4.1/faq/index.html">FAQ</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/tutorials/index.html">Tutorials</a>
<li><a class="main-nav-link" href="https://github.com/apache/incubator-mxnet/tree/1.4.1/example">Examples</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/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.4.1/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/1.4.1">Github</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/community/contribute.html">Contribute</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/community/ecosystem.html">Ecosystem</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/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.4.1<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.4.1/install/index.html">Install</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/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.4.1/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.4.1/api/python/index.html">Python</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/api/c++/index.html">C++</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/api/clojure/index.html">Clojure</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/api/java/index.html">Java</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/api/julia/index.html">Julia</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/api/perl/index.html">Perl</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/api/r/index.html">R</a></li>
<li><a class="main-nav-link" href="/versions/1.4.1/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.4.1/faq/index.html" tabindex="-1">FAQ</a></li>
<li><a href="/versions/1.4.1/tutorials/index.html" tabindex="-1">Tutorials</a></li>
<li><a href="https://github.com/apache/incubator-mxnet/tree/1.4.1/example" tabindex="-1">Examples</a></li>
<li><a href="/versions/1.4.1/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.4.1/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/1.4.1" tabindex="-1">Github</a></li>
<li><a href="/versions/1.4.1/community/contribute.html" tabindex="-1">Contribute</a></li>
<li><a href="/versions/1.4.1/community/ecosystem.html" tabindex="-1">Ecosystem</a></li>
<li><a href="/versions/1.4.1/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.4.1</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/index.html">MXNet APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../architecture/index.html">MXNet Architecture</a></li>
<li class="toctree-l1"><a class="reference internal" href="../community/index.html">MXNet Community</a></li>
<li class="toctree-l1"><a class="reference internal" href="../faq/index.html">MXNet FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="../gluon/index.html">About Gluon</a></li>
<li class="toctree-l1"><a class="reference internal" href="index.html">Installing MXNet</a></li>
<li class="toctree-l1"><a class="reference internal" href="index.html#nvidia-jetson-tx-family">Nvidia Jetson TX family</a></li>
<li class="toctree-l1"><a class="reference internal" href="index.html#source-download">Source Download</a></li>
<li class="toctree-l1"><a class="reference internal" href="../model_zoo/index.html">MXNet Model Zoo</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/index.html">Tutorials</a></li>
</ul>
</div>
</div>
<div class="content">
<div class="page-tracker"></div>
<!--- Licensed to the Apache Software Foundation (ASF) under one -->
<!--- or more contributor license agreements. See the NOTICE file -->
<!--- distributed with this work for additional information -->
<!--- regarding copyright ownership. The ASF licenses this file -->
<!--- to you under the Apache License, Version 2.0 (the -->
<!--- "License"); you may not use this file except in compliance -->
<!--- with the License. You may obtain a copy of the License at --><!--- http://www.apache.org/licenses/LICENSE-2.0 --><!--- Unless required by applicable law or agreed to in writing, -->
<!--- software distributed under the License is distributed on an -->
<!--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -->
<!--- KIND, either express or implied. See the License for the -->
<!--- specific language governing permissions and limitations -->
<!--- under the License. --><div class="section" id="build-mxnet-from-source">
<span id="build-mxnet-from-source"></span><h1>Build MXNet from Source<a class="headerlink" href="#build-mxnet-from-source" title="Permalink to this headline"></a></h1>
<p>This document explains how to build MXNet from source code.</p>
<div class="section" id="overview">
<span id="overview"></span><h2>Overview<a class="headerlink" href="#overview" title="Permalink to this headline"></a></h2>
<p>Building from source follows this general two-step flow of building the shared library, then installing your preferred language binding. Use the following links to jump to the different sections of this guide.</p>
<ol class="simple">
<li>Build the MXNet shared library, <code class="docutils literal"><span class="pre">libmxnet.so</span></code>.<ul>
<li><a class="reference external" href="#clone-the-mxnet-project">Clone the repository</a></li>
<li><a class="reference external" href="#prerequisites">Prerequisites</a><ul>
<li><a class="reference external" href="#math-library-selection">Math library selection</a></li>
<li><a class="reference external" href="#install-gpu-software">Install GPU software</a></li>
<li><a class="reference external" href="#install-optional-software">Install optional software</a></li>
</ul>
</li>
<li><a class="reference external" href="#build-configurations">Adjust your build configuration</a></li>
<li><a class="reference external" href="#build-mxnet">Build MXNet</a><ul>
<li><a class="reference external" href="#build-mxnet-with-nccl">with NCCL</a> (optional)</li>
<li><a class="reference external" href="#build-mxnet-with-c++">for C++</a> (optional)</li>
<li><a class="reference external" href="#usage-examples">Usage Examples</a><ul>
<li><a class="reference external" href="#recommended-for-Systems-with-NVIDIA-GPUs-and-Intel-CPUs">systems with GPUs and Intel CPUs</a></li>
<li><a class="reference external" href="#recommended-for-Systems-with-Intel-CPUs">GPUs with non-Intel CPUs</a></li>
<li><a class="reference external" href="#recommended-for-Systems-with-Intel-CPUs">Intel CPUs</a></li>
<li><a class="reference external" href="#recommended-for-Systems-with-non-Intel-CPUs">non-Intel CPUs</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a class="reference external" href="#installing-mxnet-language-bindings">Install the language API binding(s)</a> you would like to use for MXNet.
MXNet&#8217;s newest and most popular API is Gluon. Gluon is built into the Python binding. If Python isn&#8217;t your preference, you still have more options. MXNet supports several other language APIs:<ul>
<li><a class="reference external" href="/versions/1.4.1/api/python/index.html">Python (includes Gluon)</a></li>
<li><a class="reference external" href="/versions/1.4.1/api/c++/index.html">C++</a></li>
<li><a class="reference external" href="/versions/1.4.1/api/clojure/index.html">Clojure</a></li>
<li>Java (coming soon)</li>
<li><a class="reference external" href="/versions/1.4.1/api/julia/index.html">Julia</a></li>
<li><a class="reference external" href="/versions/1.4.1/api/perl/index.html">Perl</a></li>
<li><a class="reference external" href="/versions/1.4.1/api/r/index.html">R</a></li>
<li><a class="reference external" href="/versions/1.4.1/api/scala/index.html">Scala</a></li>
<li><a class="reference external" href="/versions/1.4.1/api/java/index.html">Java</a></li>
</ul>
</li>
</ol>
<hr>
## Build Instructions by Operating System<p>Detailed instructions are provided per operating system. Each of these guides also covers how to install the specific <a class="reference external" href="#installing-mxnet-language-bindings">Language Bindings</a> you require.
You may jump to those, but it is recommended that you continue reading to understand more general &#8220;build from source&#8221; options.</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference external" href="/versions/1.4.1/install/centos_setup.html">Amazon Linux / CentOS / RHEL</a></li>
<li class="toctree-l1"><a class="reference external" href="/versions/1.4.1/install/osx_setup.html">macOS</a></li>
<li class="toctree-l1"><a class="reference external" href="/versions/1.4.1/install/raspian_setup.html">Raspbian</a></li>
<li class="toctree-l1"><a class="reference external" href="/versions/1.4.1/install/tx2_setup.html">TX2</a></li>
<li class="toctree-l1"><a class="reference external" href="/versions/1.4.1/install/ubuntu_setup.html">Ubuntu</a></li>
<li class="toctree-l1"><a class="reference external" href="/versions/1.4.1/install/windows_setup.html">Windows</a></li>
</ul>
</div>
<hr></div>
<div class="section" id="clone-the-mxnet-project">
<span id="clone-the-mxnet-project"></span><h2>Clone the MXNet Project<a class="headerlink" href="#clone-the-mxnet-project" title="Permalink to this headline"></a></h2>
<ol class="simple">
<li>Clone or fork the MXNet project.</li>
</ol>
<div class="highlight-bash"><div class="highlight"><pre><span></span>git clone --recursive https://github.com/apache/incubator-mxnet mxnet
<span class="nb">cd</span> mxnet
</pre></div>
</div>
<hr></div>
<div class="section" id="prerequisites">
<span id="prerequisites"></span><h2>Prerequisites<a class="headerlink" href="#prerequisites" title="Permalink to this headline"></a></h2>
<p>The following sections will help you decide which specific prerequisites you need to install.</p>
<div class="section" id="math-library-selection">
<span id="math-library-selection"></span><h3>Math Library Selection<a class="headerlink" href="#math-library-selection" title="Permalink to this headline"></a></h3>
<p>It is useful to consider your math library selection prior to your other prerequisites.
MXNet relies on the
<a class="reference external" href="https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms">BLAS</a> (Basic
Linear Algebra Subprograms) library for numerical computations.
Those can be extended with <a class="reference external" href="https://github.com/Reference-LAPACK/lapack">LAPACK (Linear Algebra Package)</a>, an additional set of mathematical functions.</p>
<p>MXNet supports multiple mathematical backends for computations on the CPU:</p>
<ul class="simple">
<li><a class="reference external" href="https://developer.apple.com/documentation/accelerate">Apple Accelerate</a></li>
<li><a class="reference external" href="http://math-atlas.sourceforge.net/">ATLAS</a></li>
<li><a class="reference external" href="https://software.intel.com/en-us/intel-mkl">MKL</a> (MKL, MKLML)</li>
<li><a class="reference external" href="https://github.com/intel/mkl-dnn">MKL-DNN</a></li>
<li><a class="reference external" href="http://www.openblas.net/">OpenBLAS</a></li>
</ul>
<p>The default order of choice for the libraries if found follows the path from the most
(recommended) to less performant backends.
The following lists show this order by library and <code class="docutils literal"><span class="pre">cmake</span></code> switch.</p>
<p>For desktop platforms (x86_64):</p>
<ol class="simple">
<li>MKL-DNN (submodule) | <code class="docutils literal"><span class="pre">USE_MKLDNN</span></code></li>
<li>MKL | <code class="docutils literal"><span class="pre">USE_MKL_IF_AVAILABLE</span></code></li>
<li>MKLML (downloaded) | <code class="docutils literal"><span class="pre">USE_MKLML</span></code></li>
<li>Apple Accelerate | <code class="docutils literal"><span class="pre">USE_APPLE_ACCELERATE_IF_AVAILABLE</span></code> | Mac only</li>
<li>OpenBLAS | <code class="docutils literal"><span class="pre">BLAS</span></code> | Options: Atlas, Open, MKL, Apple</li>
</ol>
<p>Note: If <code class="docutils literal"><span class="pre">USE_MKL_IF_AVAILABLE</span></code> is set to False then MKLML and MKL-DNN will be disabled as well for configuration
backwards compatibility.</p>
<p>For embedded platforms (all other and if cross compiled):</p>
<ol class="simple">
<li>OpenBLAS | <code class="docutils literal"><span class="pre">BLAS</span></code> | Options: Atlas, Open, MKL, Apple</li>
</ol>
<p>You can set the BLAS library explicitly by setting the BLAS variable to:</p>
<ul class="simple">
<li>Atlas</li>
<li>Open</li>
<li>MKL</li>
<li>Apple</li>
</ul>
<p>See the <a class="reference external" href="https://github.com/apache/incubator-mxnet/blob/master/cmake/ChooseBlas.cmake">cmake/ChooseBLAS.cmake</a> file for the options.</p>
<p>Intel&#8217;s MKL (Math Kernel Library) is one of the most powerful math libraries
https://software.intel.com/en-us/mkl</p>
<p>It has following flavors:</p>
<ul class="simple">
<li>MKL is a complete math library, containing all the functionality found in ATLAS, OpenBlas and LAPACK. It is free under
community support licensing (https://software.intel.com/en-us/articles/free-mkl),
but needs to be downloaded and installed manually.</li>
<li>MKLML is a subset of MKL. It contains a smaller number of functions to reduce the
size of the download and reduce the number of dynamic libraries user needs.</li>
</ul>
<!-- [Removed until #11148 is merged.] This is the most effective option since it can be downloaded and installed automatically
by the cmake script (see cmake/DownloadMKLML.cmake).--><ul class="simple">
<li>MKL-DNN is a separate open-source library, it can be used separately from MKL or MKLML. It is
shipped as a subrepo with MXNet source code (see 3rdparty/mkldnn or the <a class="reference external" href="https://github.com/intel/mkl-dnn">MKL-DNN project</a>)</li>
</ul>
<p>Since the full MKL library is almost always faster than any other BLAS library it&#8217;s turned on by default,
however it needs to be downloaded and installed manually before doing <code class="docutils literal"><span class="pre">cmake</span></code> configuration.
Register and download on the <a class="reference external" href="https://software.intel.com/en-us/performance-libraries">Intel performance libraries website</a>.</p>
<p>Note: MKL is supported only for desktop builds and the framework itself supports the following
hardware:</p>
<ul class="simple">
<li>Intel® Xeon Phi™ processor</li>
<li>Intel® Xeon® processor</li>
<li>Intel® Core™ processor family</li>
<li>Intel Atom® processor</li>
</ul>
<p>If you have a different processor you can still try to use MKL, but performance results are
unpredictable.</p>
</div>
<div class="section" id="install-gpu-software">
<span id="install-gpu-software"></span><h3>Install GPU Software<a class="headerlink" href="#install-gpu-software" title="Permalink to this headline"></a></h3>
<p>If you want to run MXNet with GPUs, you must install <a class="reference external" href="https://developer.nvidia.com/cuda-downloads">NVDIA CUDA and cuDNN</a>.</p>
</div>
<div class="section" id="install-optional-software">
<span id="install-optional-software"></span><h3>Install Optional Software<a class="headerlink" href="#install-optional-software" title="Permalink to this headline"></a></h3>
<p>These might be optional, but they&#8217;re typically desirable as the extend or enhance MXNet&#8217;s functionality.</p>
<ul class="simple">
<li><a class="reference external" href="http://opencv.org/">OpenCV</a> - Image Loading and Augmentation. Each operating system has different packages and build from source options for OpenCV. Refer to your OS&#8217;s link in the <a class="reference external" href="#build-instructions-by-operating-system">Build Instructions by Operating System</a> section for further instructions.</li>
<li><a class="reference external" href="https://developer.nvidia.com/nccl">NCCL</a> - NVIDIA&#8217;s Collective Communications Library. Instructions for installing NCCL are found in the following <a class="reference external" href="#build-mxnet-with-nccl">Build MXNet with NCCL</a> section.</li>
</ul>
<p>More information on turning these features on or off are found in the following <a class="reference external" href="#build-configurations">build configurations</a> section.</p>
<hr></div>
</div>
<div class="section" id="build-configurations">
<span id="build-configurations"></span><h2>Build Configurations<a class="headerlink" href="#build-configurations" title="Permalink to this headline"></a></h2>
<p>There is a configuration file for make,
<a class="reference external" href="https://github.com/apache/incubator-mxnet/blob/master/make/config.mk"><code class="docutils literal"><span class="pre">make/config.mk</span></code></a>, that contains all the compilation options. You can edit it and then run <code class="docutils literal"><span class="pre">make</span></code> or <code class="docutils literal"><span class="pre">cmake</span></code>. <code class="docutils literal"><span class="pre">cmake</span></code> is recommended for building MXNet (and is required to build with MKLDNN), however you may use <code class="docutils literal"><span class="pre">make</span></code> instead.</p>
<hr></div>
<div class="section" id="build-mxnet">
<span id="build-mxnet"></span><h2>Build MXNet<a class="headerlink" href="#build-mxnet" title="Permalink to this headline"></a></h2>
<div class="section" id="build-mxnet-with-nccl">
<span id="build-mxnet-with-nccl"></span><h3>Build MXNet with NCCL<a class="headerlink" href="#build-mxnet-with-nccl" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li>Download and install the latest NCCL library from NVIDIA.</li>
<li>Note the directory path in which NCCL libraries and header files are installed.</li>
<li>Ensure that the installation directory contains <code class="docutils literal"><span class="pre">lib</span></code> and <code class="docutils literal"><span class="pre">include</span></code> folders.</li>
<li>Ensure that the prerequisites for using NCCL such as Cuda libraries are met.</li>
<li>Append the <code class="docutils literal"><span class="pre">config.mk</span></code> file with following, in addition to the CUDA related options.</li>
<li>USE_NCCL=1</li>
<li>USE_NCCL_PATH=path-to-nccl-installation-folder</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="nb">echo</span> <span class="s2">&quot;USE_NCCL=1&quot;</span> &gt;&gt; make/config.mk
<span class="nb">echo</span> <span class="s2">&quot;USE_NCCP_PATH=path-to-nccl-installation-folder&quot;</span> &gt;&gt; make/config.mk
cp make/config.mk .
</pre></div>
</div>
<ul class="simple">
<li>Run make command</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>make -j<span class="s2">&quot;</span><span class="k">$(</span>nproc<span class="k">)</span><span class="s2">&quot;</span>
</pre></div>
</div>
<div class="section" id="validating-nccl">
<span id="validating-nccl"></span><h4>Validating NCCL<a class="headerlink" href="#validating-nccl" title="Permalink to this headline"></a></h4>
<ul class="simple">
<li>Follow the steps to install MXNet Python binding.</li>
<li>Comment the following line in <code class="docutils literal"><span class="pre">test_nccl.py</span></code> file at <code class="docutils literal"><span class="pre">incubator-mxnet/tests/python/gpu/test_nccl.py</span></code></li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>@unittest.skip<span class="o">(</span><span class="s2">&quot;Test requires NCCL library installed and enabled during build&quot;</span><span class="o">)</span>
</pre></div>
</div>
<ul class="simple">
<li>Run test_nccl.py script as follows. The test should complete. It does not produce any output.</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>nosetests --verbose tests/python/gpu/test_nccl.py
</pre></div>
</div>
<p><strong>Recommendation to get the best performance out of NCCL:</strong>
It is recommended to set environment variable NCCL_LAUNCH_MODE to PARALLEL when using NCCL version 2.1 or newer.</p>
<hr></div>
</div>
<div class="section" id="build-mxnet-with-c">
<span id="build-mxnet-with-c"></span><h3>Build MXNet with C++<a class="headerlink" href="#build-mxnet-with-c" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li>To enable C++ package, just add <code class="docutils literal"><span class="pre">USE_CPP_PACKAGE=1</span></code> when you run <code class="docutils literal"><span class="pre">make</span></code> or <code class="docutils literal"><span class="pre">cmake</span></code>.</li>
</ul>
<hr></div>
<div class="section" id="usage-examples">
<span id="usage-examples"></span><h3>Usage Examples<a class="headerlink" href="#usage-examples" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">-j</span></code> runs multiple jobs against multi-core CPUs.</li>
</ul>
<p>For example, you can specify using all cores on Linux as follows:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake -j<span class="k">$(</span>nproc<span class="k">)</span>
</pre></div>
</div>
<div class="section" id="recommended-for-systems-with-nvidia-gpus-and-intel-cpus">
<span id="recommended-for-systems-with-nvidia-gpus-and-intel-cpus"></span><h4>Recommended for Systems with NVIDIA GPUs and Intel CPUs<a class="headerlink" href="#recommended-for-systems-with-nvidia-gpus-and-intel-cpus" title="Permalink to this headline"></a></h4>
<ul class="simple">
<li>Build MXNet with <code class="docutils literal"><span class="pre">cmake</span></code> and install with MKL DNN, GPU, and OpenCV support:</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake -j <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> <span class="nv">USE_MKLDNN</span><span class="o">=</span><span class="m">1</span>
</pre></div>
</div>
</div>
<div class="section" id="recommended-for-systems-with-nvidia-gpus">
<span id="recommended-for-systems-with-nvidia-gpus"></span><h4>Recommended for Systems with NVIDIA GPUs<a class="headerlink" href="#recommended-for-systems-with-nvidia-gpus" title="Permalink to this headline"></a></h4>
<ul class="simple">
<li>Build with both OpenBLAS, GPU, and OpenCV support:</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake -j <span class="nv">BLAS</span><span class="o">=</span>open <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>
</div>
<div class="section" id="recommended-for-systems-with-intel-cpus">
<span id="recommended-for-systems-with-intel-cpus"></span><h4>Recommended for Systems with Intel CPUs<a class="headerlink" href="#recommended-for-systems-with-intel-cpus" title="Permalink to this headline"></a></h4>
<ul class="simple">
<li>Build MXNet with <code class="docutils literal"><span class="pre">cmake</span></code> and install with MKL DNN, and OpenCV support:</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake -j <span class="nv">USE_CUDA</span><span class="o">=</span><span class="m">0</span> <span class="nv">USE_MKLDNN</span><span class="o">=</span><span class="m">1</span>
</pre></div>
</div>
</div>
<div class="section" id="recommended-for-systems-with-non-intel-cpus">
<span id="recommended-for-systems-with-non-intel-cpus"></span><h4>Recommended for Systems with non-Intel CPUs<a class="headerlink" href="#recommended-for-systems-with-non-intel-cpus" title="Permalink to this headline"></a></h4>
<ul class="simple">
<li>Build MXNet with <code class="docutils literal"><span class="pre">cmake</span></code> and install with OpenBLAS and OpenCV support:</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake -j <span class="nv">USE_CUDA</span><span class="o">=</span><span class="m">0</span> <span class="nv">BLAS</span><span class="o">=</span>open
</pre></div>
</div>
</div>
<div class="section" id="other-examples">
<span id="other-examples"></span><h4>Other Examples<a class="headerlink" href="#other-examples" title="Permalink to this headline"></a></h4>
<ul class="simple">
<li>Build without using OpenCV:</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake <span class="nv">USE_OPENCV</span><span class="o">=</span><span class="m">0</span>
</pre></div>
</div>
<ul class="simple">
<li>Build on <strong>macOS</strong> with the default BLAS library (Apple Accelerate) and Clang installed with <code class="docutils literal"><span class="pre">xcode</span></code> (OPENMP is disabled because it is not supported by the Apple version of Clang):</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>cmake -j <span class="nv">BLAS</span><span class="o">=</span>apple <span class="nv">USE_OPENCV</span><span class="o">=</span><span class="m">0</span> <span class="nv">USE_OPENMP</span><span class="o">=</span><span class="m">0</span>
</pre></div>
</div>
<ul class="simple">
<li>To use OpenMP on <strong>macOS</strong> you need to install the Clang compiler, <code class="docutils literal"><span class="pre">llvm</span></code> (the one provided by Apple does not support OpenMP):</li>
</ul>
<div class="highlight-bash"><div class="highlight"><pre><span></span>brew install llvm
cmake -j <span class="nv">BLAS</span><span class="o">=</span>apple <span class="nv">USE_OPENMP</span><span class="o">=</span><span class="m">1</span>
</pre></div>
</div>
<hr></div>
</div>
</div>
<div class="section" id="installing-mxnet-language-bindings">
<span id="installing-mxnet-language-bindings"></span><h2>Installing MXNet Language Bindings<a class="headerlink" href="#installing-mxnet-language-bindings" title="Permalink to this headline"></a></h2>
<p>After building MXNet&#8217;s shared library, you can install other language bindings.</p>
<p><strong>NOTE:</strong> The C++ API binding must be built when you build MXNet from source. See <a class="reference external" href="#build-mxnet-with-c++">Build MXNet with C++</a>.</p>
<p>The following table provides links to each language binding by operating system:</p>
<table border="1" class="docutils">
<colgroup>
<col width="25%" />
<col width="25%" />
<col width="25%" />
<col width="25%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">&#160;</th>
<th class="head"><a class="reference external" href="ubuntu_setup.html">Ubuntu</a></th>
<th class="head"><a class="reference external" href="osx_setup.html">macOS</a></th>
<th class="head"><a class="reference external" href="windows_setup.html">Windows</a></th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Python</td>
<td><a class="reference external" href="ubuntu_setup.html#install-mxnet-for-python">Ubuntu guide</a></td>
<td><a class="reference external" href="osx_setup.html">OSX guide</a></td>
<td><a class="reference external" href="windows_setup.html#install-mxnet-for-python">Windows guide</a></td>
</tr>
<tr class="row-odd"><td>C++</td>
<td><a class="reference external" href="c_plus_plus.html">C++ guide</a></td>
<td><a class="reference external" href="c_plus_plus.html">C++ guide</a></td>
<td><a class="reference external" href="c_plus_plus.html">C++ guide</a></td>
</tr>
<tr class="row-even"><td>Clojure</td>
<td><a class="reference external" href="https://github.com/apache/incubator-mxnet/tree/master/contrib/clojure-package">Clojure guide</a></td>
<td><a class="reference external" href="https://github.com/apache/incubator-mxnet/tree/master/contrib/clojure-package">Clojure guide</a></td>
<td>n/a</td>
</tr>
<tr class="row-odd"><td>Julia</td>
<td><a class="reference external" href="ubuntu_setup.html#install-the-mxnet-package-for-julia">Ubuntu guide</a></td>
<td><a class="reference external" href="osx_setup.html#install-the-mxnet-package-for-julia">OSX guide</a></td>
<td><a class="reference external" href="windows_setup.html#install-the-mxnet-package-for-julia">Windows guide</a></td>
</tr>
<tr class="row-even"><td>Perl</td>
<td><a class="reference external" href="ubuntu_setup.html#install-the-mxnet-package-for-perl">Ubuntu guide</a></td>
<td><a class="reference external" href="osx_setup.html#install-the-mxnet-package-for-perl">OSX guide</a></td>
<td>n/a</td>
</tr>
<tr class="row-odd"><td>R</td>
<td><a class="reference external" href="ubuntu_setup.html#install-the-mxnet-package-for-r">Ubuntu guide</a></td>
<td><a class="reference external" href="osx_setup.html#install-the-mxnet-package-for-r">OSX guide</a></td>
<td><a class="reference external" href="windows_setup.html#install-the-mxnet-package-for-r">Windows guide</a></td>
</tr>
<tr class="row-even"><td>Scala</td>
<td><a class="reference external" href="scala_setup.html">Scala guide</a></td>
<td><a class="reference external" href="scala_setup.html">Scala guide</a></td>
<td>n/a</td>
</tr>
<tr class="row-odd"><td>Java</td>
<td><a class="reference external" href="java_setup.html">Java guide</a></td>
<td><a class="reference external" href="java_setup.html">Java Guide</a></td>
<td>n/a</td>
</tr>
</tbody>
</table>
</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="#">Build MXNet from Source</a><ul>
<li><a class="reference internal" href="#overview">Overview</a></li>
<li><a class="reference internal" href="#clone-the-mxnet-project">Clone the MXNet Project</a></li>
<li><a class="reference internal" href="#prerequisites">Prerequisites</a><ul>
<li><a class="reference internal" href="#math-library-selection">Math Library Selection</a></li>
<li><a class="reference internal" href="#install-gpu-software">Install GPU Software</a></li>
<li><a class="reference internal" href="#install-optional-software">Install Optional Software</a></li>
</ul>
</li>
<li><a class="reference internal" href="#build-configurations">Build Configurations</a></li>
<li><a class="reference internal" href="#build-mxnet">Build MXNet</a><ul>
<li><a class="reference internal" href="#build-mxnet-with-nccl">Build MXNet with NCCL</a><ul>
<li><a class="reference internal" href="#validating-nccl">Validating NCCL</a></li>
</ul>
</li>
<li><a class="reference internal" href="#build-mxnet-with-c">Build MXNet with C++</a></li>
<li><a class="reference internal" href="#usage-examples">Usage Examples</a><ul>
<li><a class="reference internal" href="#recommended-for-systems-with-nvidia-gpus-and-intel-cpus">Recommended for Systems with NVIDIA GPUs and Intel CPUs</a></li>
<li><a class="reference internal" href="#recommended-for-systems-with-nvidia-gpus">Recommended for Systems with NVIDIA GPUs</a></li>
<li><a class="reference internal" href="#recommended-for-systems-with-intel-cpus">Recommended for Systems with Intel CPUs</a></li>
<li><a class="reference internal" href="#recommended-for-systems-with-non-intel-cpus">Recommended for Systems with non-Intel CPUs</a></li>
<li><a class="reference internal" href="#other-examples">Other Examples</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#installing-mxnet-language-bindings">Installing MXNet Language Bindings</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>