blob: 3cc11298b33b2d19dd85ed5344dc6390ee186b44 [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">
<link href="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-icon.png" rel="icon" type="image/png"><!-- Begin Jekyll SEO tag v2.6.1 -->
<title>Ubuntu Setup | Apache MXNet</title>
<meta name="generator" content="Jekyll v3.8.6" />
<meta property="og:title" content="Ubuntu Setup" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="A flexible and efficient library for deep learning." />
<meta property="og:description" content="A flexible and efficient library for deep learning." />
<link rel="canonical" href="https://mxnet.apache.org/get_started/ubuntu_setup" />
<meta property="og:url" content="https://mxnet.apache.org/get_started/ubuntu_setup" />
<meta property="og:site_name" content="Apache MXNet" />
<script type="application/ld+json">
{"description":"A flexible and efficient library for deep learning.","headline":"Ubuntu Setup","@type":"WebPage","url":"https://mxnet.apache.org/get_started/ubuntu_setup","@context":"https://schema.org"}</script>
<!-- End Jekyll SEO tag -->
<script src="https://medium-widget.pixelpoint.io/widget.js"></script>
<link rel="stylesheet" href="/versions/1.6/assets/main.css"><link type="application/atom+xml" rel="alternate" href="https://mxnet.apache.org/feed.xml" title="Apache MXNet" /><script>
if(!(window.doNotTrack === "1" || navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1")) {
(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 src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="/versions/1.6/assets/js/clipboard.js"></script>
<script src="/versions/1.6/assets/js/copycode.js"></script>
<script src="/versions/1.6/assets/js/globalSearch.js"></script>
<style>
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 1;
text-align: left;
}
.dropdown:hover .dropdown-content {
display: block;
}
</style>
</head>
<body><header class="site-header" role="banner">
<script>
$(document).ready(function () {
// HEADER OPACITY LOGIC
function opacity_header() {
var value = "rgba(4,140,204," + ($(window).scrollTop() / 300 + 0.4) + ")"
$('.site-header').css("background-color", value)
}
$(window).scroll(function () {
opacity_header()
})
opacity_header();
// MENU SELECTOR LOGIC
$('.page-link').each( function () {
if (window.location.href.includes(this.href)) {
$(this).addClass("page-current");
}
});
})
</script>
<div class="wrapper">
<a class="site-title" rel="author" href="/versions/1.6/"><img
src="/versions/1.6/assets/img/mxnet_logo.png" class="site-header-logo"></a>
<nav class="site-nav">
<input type="checkbox" id="nav-trigger" class="nav-trigger"/>
<label for="nav-trigger">
<span class="menu-icon">
<svg viewBox="0 0 18 15" width="18px" height="15px">
<path d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.032C17.335,0,18,0.665,18,1.484L18,1.484z M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.032C17.335,6.031,18,6.696,18,7.516L18,7.516z M18,13.516C18,14.335,17.335,15,16.516,15H1.484 C0.665,15,0,14.335,0,13.516l0,0c0-0.82,0.665-1.483,1.484-1.483h15.032C17.335,12.031,18,12.695,18,13.516L18,13.516z"/>
</svg>
</span>
</label>
<div class="trigger">
<a class="page-link" href="/versions/1.6/get_started">Get Started</a>
<a class="page-link" href="/versions/1.6/blog">Blog</a>
<a class="page-link" href="/versions/1.6/features">Features</a>
<a class="page-link" href="/versions/1.6/ecosystem">Ecosystem</a>
<a class="page-link" href="/versions/1.6/api">Docs & Tutorials</a>
<a class="page-link" href="https://github.com/apache/incubator-mxnet">GitHub</a>
<div class="dropdown">
<span style="display:inline-flex;">1.6
<svg viewBox="0 0 32 32" class="icon icon-caret-bottom" aria-hidden="true" style="width: 18px;"><path d="M24 11.305l-7.997 11.39L8 11.305z" style="fill: white;"></path></svg>
</span>
<div class="dropdown-content">
<a href="/">master</a>
<a href="/versions/1.7/">1.7</a>
<a style="color:#FF4500;" href="/versions/1.6/">1.6</a>
<a href="/versions/1.5.0/">1.5.0</a>
<a href="/versions/1.4.1/">1.4.1</a>
<a href="/versions/1.3.1/">1.3.1</a>
<a href="/versions/1.2.1/">1.2.1</a>
<a href="/versions/1.1.0/">1.1.0</a>
<a href="/versions/1.0.0/">1.0.0</a>
<a href="/versions/0.12.1/">0.12.1</a>
<a href="/versions/0.11.0/">0.11.0</a>
</div>
</div>
</div>
</nav>
</div>
</header>
<main class="page-content" aria-label="Content">
<script>
</script>
<article class="post">
<header class="post-header wrapper">
<h1 class="post-title">Ubuntu Setup</h1>
<h3></h3><a style="float:left; margin-top:20px" href="/versions/1.6/get_started" class="btn btn-action">Get Started
<span class="span-accented"></span></a></header>
<div class="post-content">
<div class="wrapper">
<!--- 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. -->
<h1 id="installing-mxnet-on-ubuntu">Installing MXNet on Ubuntu</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 href="#contributions">not yet available</a>.
<hr></p>
<h2 id="contents">Contents</h2>
<ul>
<li><a href="#cuda-dependencies">CUDA Dependencies</a></li>
<li><a href="#quick-installation">Quick Installation</a>
<ul>
<li><a href="#install-mxnet-for-python">Python</a></li>
<li><a href="#pip-package-availability">pip Packages</a></li>
</ul></li>
<li><a href="#build-mxnet-from-source">Build from Source</a></li>
<li><a href="#installing-language-packages-for-mxnet">Installing Language Packages</a>
<ul>
<li><a href="#install-the-mxnet-package-for-r">R</a></li>
<li><a href="#install-the-mxnet-package-for-julia">Julia</a></li>
<li><a href="#install-the-mxnet-package-for-scala">Scala</a></li>
<li><a href="#install-the-mxnet-package-for-java">Java</a></li>
<li><a href="#install-the-mxnet-package-for-perl">Perl</a></li>
<li><a href="#contributions">Contributions</a></li>
<li><a href="#next-steps">Next Steps</a></li>
</ul></li>
</ul>
<p><hr></p>
<h2 id="cuda-dependencies">CUDA Dependencies</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 href="https://developer.nvidia.com/cuda-toolkit">CUDA toolkit</a>. CUDA 9.2 is recommended.</p>
<p>Then download <a 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"><pre><code class="language-bash" data-lang="bash"> <span class="nb">tar </span>xvzf cudnn-9.2-linux-x64-v7.1
<span class="nb">sudo cp</span> <span class="nt">-P</span> cuda/include/cudnn.h /usr/local/cuda/include
<span class="nb">sudo cp</span> <span class="nt">-P</span> cuda/lib64/libcudnn<span class="k">*</span> /usr/local/cuda/lib64
<span class="nb">sudo chmod </span>a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn<span class="k">*</span>
<span class="nb">sudo </span>ldconfig
</code></pre></div>
<p><hr></p>
<h2 id="quick-installation">Quick Installation</h2>
<h3 id="install-mxnet-for-python">Install MXNet for Python</h3>
<h4 id="dependencies">Dependencies</h4>
<p>The following scripts will install Ubuntu 16.04 dependencies for MXNet Python development.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash">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
<span class="nb">sudo</span> ./ubuntu_core.sh
<span class="nb">sudo</span> ./ubuntu_python.sh
</code></pre></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>
<code>bash
pip install mxnet-cu92
</code></p>
<p><strong>Recommended for inference:</strong>
<code>bash
pip install mxnet-cu92mkl
</code></p>
<p>Alternatively, you can use the table below to select the package that suits your purpose.</p>
<table><thead>
<tr>
<th>MXNet Version</th>
<th>Basic</th>
<th>CUDA</th>
<th>MKL-DNN</th>
<th>CUDA/MKL-DNN</th>
</tr>
</thead><tbody>
<tr>
<td>Latest</td>
<td>mxnet</td>
<td>mxnet-cu92</td>
<td>mxnet-mkl</td>
<td>mxnet-cu92mkl</td>
</tr>
</tbody></table>
<h4 id="pip-package-availability">pip Package Availability</h4>
<p>The following table presents the pip packages that are recommended for each version of MXNet.</p>
<p><img src="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/install/pip-packages-1.4.0.png" alt="pip package table"></p>
<p>To install an older version of MXNet with one of the packages in the previous table add <code>==</code> with the version you require. For example for version 1.1.0 of MXNet with CUDA 8, you would use <code>pip install mxnet-cu80==1.1.0</code>.</p>
<p><hr></p>
<h2 id="build-mxnet-from-source">Build MXNet from Source</h2>
<p>You can build MXNet from source, and then you have the option of installing language-specific bindings, such as Scala, Java, Julia, R or Perl. This is a two-step process:</p>
<ol>
<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>
<li><a href="#install-the-mxnet-package-for-r">R</a></li>
<li><a href="#install-the-mxnet-package-for-julia">Julia</a></li>
<li><a href="#install-the-mxnet-package-for-scala">Scala</a></li>
<li><a href="#install-the-mxnet-package-for-java">Java</a></li>
<li><a 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>make/config.mk</code> file prior to building MXNet. More information on this is mentioned in the different language package instructions.</p>
<h3 id="build-the-shared-library">Build the Shared Library</h3>
<h4 id="quick-mxnet-build">Quick MXNet Build</h4>
<p>You can quickly build MXNet from source with the following script found in the <code>/docs/install</code> folder:</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">cd </span>docs/install
./install_mxnet_ubuntu_python.sh
</code></pre></div>
<p>Or you can go through a manual process described next.</p>
<h4 id="manual-mxnet-installation">Manual MXNet Installation</h4>
<p>It is recommended that you review the general <a href="build_from_source">build from source</a> instructions before continuing.</p>
<p>On Ubuntu versions 16.04 or later, you need the following dependencies:</p>
<p><strong>Step 1:</strong> Install prerequisite packages.
<code>bash
sudo apt-get update
sudo apt-get install -y build-essential git ninja-build ccache
</code></p>
<p><strong>For Ubuntu 18.04 and CUDA builds you need to update CMake</strong></p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c">#!/usr/bin/env bash</span>
<span class="nb">set</span> <span class="nt">-exuo</span> pipefail
<span class="nb">sudo </span>apt remove <span class="nt">--purge</span> <span class="nt">--auto-remove</span> cmake
<span class="c"># Update CMAKE for correct cuda autotedetection: https://github.com/clab/dynet/issues/1457</span>
<span class="nv">version</span><span class="o">=</span>3.14
<span class="nv">build</span><span class="o">=</span>0
<span class="nb">mkdir</span> <span class="nt">-p</span> ~/tmp
<span class="nb">cd</span> ~/tmp
wget https://cmake.org/files/v<span class="nv">$version</span>/cmake-<span class="nv">$version</span>.<span class="nv">$build</span>.tar.gz
<span class="nb">tar</span> <span class="nt">-xzvf</span> cmake-<span class="nv">$version</span>.<span class="nv">$build</span>.tar.gz
<span class="nb">cd </span>cmake-<span class="nv">$version</span>.<span class="nv">$build</span>/
./bootstrap
make <span class="nt">-j</span><span class="si">$(</span><span class="nb">nproc</span><span class="si">)</span>
<span class="nb">sudo </span>make <span class="nb">install</span>
</code></pre></div>
<p><strong>Step 2:</strong> Install a Math Library.</p>
<p>Details on the different math libraries are found in the build from source guide&#39;s <a href="build_from_source#math-library-selection">Math Library Selection</a> section.</p>
<p>For OpenBLAS use:</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"> <span class="nb">sudo </span>apt-get <span class="nb">install</span> <span class="nt">-y</span> libopenblas-dev
</code></pre></div>
<p>For other libraries, visit the <a href="build_from_source#math-library-selection">Math Library Selection</a> section.</p>
<p><strong>Step 3:</strong> Install OpenCV.</p>
<p><em>MXNet</em> uses <a href="http://opencv.org/">OpenCV</a> for efficient image loading and augmentation operations.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"> <span class="nb">sudo </span>apt-get <span class="nb">install</span> <span class="nt">-y</span> libopencv-dev
</code></pre></div>
<p><strong>Step 4:</strong> Download MXNet sources and build MXNet core shared library.</p>
<p>If building on CPU and using OpenBLAS:</p>
<p>Clone the repository:</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"> git clone <span class="nt">--recursive</span> https://github.com/apache/incubator-mxnet.git
<span class="nb">cd </span>incubator-mxnet
</code></pre></div>
<p>Build with CMake and ninja, without GPU and without MKL.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"> <span class="nb">rm</span> <span class="nt">-rf</span> build
<span class="nb">mkdir</span> <span class="nt">-p</span> build <span class="o">&amp;&amp;</span> <span class="nb">cd </span>build
cmake <span class="nt">-GNinja</span> <span class="se">\</span>
<span class="nt">-DUSE_CUDA</span><span class="o">=</span>OFF <span class="se">\</span>
<span class="nt">-DUSE_MKL_IF_AVAILABLE</span><span class="o">=</span>OFF <span class="se">\</span>
<span class="nt">-DCMAKE_CUDA_COMPILER_LAUNCHER</span><span class="o">=</span>ccache <span class="se">\</span>
<span class="nt">-DCMAKE_C_COMPILER_LAUNCHER</span><span class="o">=</span>ccache <span class="se">\</span>
<span class="nt">-DCMAKE_CXX_COMPILER_LAUNCHER</span><span class="o">=</span>ccache <span class="se">\</span>
<span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
..
ninja
</code></pre></div>
<p>If building on CPU and using MKL and MKL-DNN (make sure MKL is installed according to <a href="build_from_source#math-library-selection">Math Library Selection</a> and <a href="https://mxnet.apache.org/api/python/docs/tutorials/performance/backend/mkldnn/mkldnn_readme.html">MKL-DNN README</a>):</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"> <span class="nb">rm</span> <span class="nt">-rf</span> build
<span class="nb">mkdir</span> <span class="nt">-p</span> build <span class="o">&amp;&amp;</span> <span class="nb">cd </span>build
cmake <span class="nt">-GNinja</span> <span class="se">\</span>
<span class="nt">-DUSE_CUDA</span><span class="o">=</span>OFF <span class="se">\</span>
<span class="nt">-DUSE_MKL_IF_AVAILABLE</span><span class="o">=</span>ON <span class="se">\</span>
<span class="nt">-DCMAKE_CUDA_COMPILER_LAUNCHER</span><span class="o">=</span>ccache <span class="se">\</span>
<span class="nt">-DCMAKE_C_COMPILER_LAUNCHER</span><span class="o">=</span>ccache <span class="se">\</span>
<span class="nt">-DCMAKE_CXX_COMPILER_LAUNCHER</span><span class="o">=</span>ccache <span class="se">\</span>
<span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
..
ninja
</code></pre></div>
<p>If building on GPU (make sure you have installed the <a href="#cuda-dependencies">CUDA dependencies first</a>):
Cuda 10.1 in Ubuntu 18.04 builds fine but is not currently tested in CI.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"> <span class="nb">rm</span> <span class="nt">-rf</span> build
<span class="nb">mkdir</span> <span class="nt">-p</span> build <span class="o">&amp;&amp;</span> <span class="nb">cd </span>build
cmake <span class="nt">-GNinja</span> <span class="se">\</span>
<span class="nt">-DUSE_CUDA</span><span class="o">=</span>ON <span class="se">\</span>
<span class="nt">-DUSE_MKL_IF_AVAILABLE</span><span class="o">=</span>OFF <span class="se">\</span>
<span class="nt">-DCMAKE_CUDA_COMPILER_LAUNCHER</span><span class="o">=</span>ccache <span class="se">\</span>
<span class="nt">-DCMAKE_C_COMPILER_LAUNCHER</span><span class="o">=</span>ccache <span class="se">\</span>
<span class="nt">-DCMAKE_CXX_COMPILER_LAUNCHER</span><span class="o">=</span>ccache <span class="se">\</span>
<span class="nt">-DCMAKE_BUILD_TYPE</span><span class="o">=</span>Release <span class="se">\</span>
..
ninja
</code></pre></div>
<p><em>Note</em> - You can explore and use more compilation options as they are delcared in the top of <code>CMakeLists.txt</code> and also review common <a href="build_from_source#usage-examples">usage examples</a>.
Optionally, you can also use a higher level, scripted version of the above with an editable CMake options file by doing the
following:</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">cp </span>cmake/cmake_options.yml <span class="nb">.</span>
<span class="c"># Edit cmake_options.yml in the MXNet root to your taste</span>
<span class="nv">$EDITOR</span> cmake_options.yml
<span class="c"># Launch a local CMake build</span>
./dev_menu.py build
</code></pre></div>
<p>Building from source creates a library called <code>libmxnet.so</code> in the <code>build</code> folder in your MXNet project root.</p>
<p>After building the MXNet library, you may install language bindings.</p>
<p><hr></p>
<h2 id="installing-language-packages-for-mxnet">Installing Language Packages for MXNet</h2>
<p>After you have installed the MXNet core library. You may install MXNet interface packages for the programming language of your choice:
- <a href="#install-mxnet-for-python">Python</a>
- <a href="#install-the-mxnet-package-for-c&plus;&plus;">C++</a>
- <a href="#install-the-mxnet-package-for-clojure">Clojure</a>
- <a href="#install-the-mxnet-package-for-julia">Julia</a>
- <a href="#install-the-mxnet-package-for-perl">Perl</a>
- <a href="#install-the-mxnet-package-for-r">R</a>
- <a href="#install-the-mxnet-package-for-scala">Scala</a>
- <a href="#install-the-mxnet-package-for-java">Java</a></p>
<p><hr></p>
<h3 id="install-mxnet-for-python">Install MXNet for Python</h3>
<p>To install the MXNet Python binding navigate to the root of the MXNet folder then run the following:</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nv">$ </span><span class="nb">cd </span>python
<span class="nv">$ </span>pip <span class="nb">install</span> <span class="nt">-e</span> <span class="nb">.</span>
</code></pre></div>
<p>Note that the <code>-e</code> flag is optional. It is equivalent to <code>--editable</code> and means that if you edit the source files, these changes will be reflected in the package installed.</p>
<h4 id="optional-python-packages">Optional Python Packages</h4>
<p>You may optionally install <code>graphviz</code> library that is used for visualizing network graphs you build on MXNet. You may also install <a href="http://jupyter.readthedocs.io/">Jupyter Notebook</a> which is used for running MXNet tutorials and examples.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">sudo </span>pip <span class="nb">install </span><span class="nv">graphviz</span><span class="o">==</span>0.8.4 <span class="se">\</span>
jupyter
</code></pre></div>
<p><hr></p>
<h3 id="install-the-mxnet-package-for-c">Install the MXNet Package for C++</h3>
<p>Refer to the <a href="c_plus_plus">C++ Package setup guide</a>.
<hr></p>
<h3 id="install-the-mxnet-package-for-clojure">Install the MXNet Package for Clojure</h3>
<p>Refer to the <a href="https://github.com/apache/incubator-mxnet/tree/master/contrib/clojure-package">Clojure setup guide</a>.
<hr></p>
<h3 id="install-the-mxnet-package-for-julia">Install the MXNet Package for Julia</h3>
<h4 id="install-julia">Install Julia</h4>
<p>The package available through <code>apt-get</code> is old and not compatible with the latest version of MXNet.
Fetch the latest version (1.0.3 at the time of this writing).</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash">wget <span class="nt">-qO</span> julia-10.tar.gz https://julialang-s3.julialang.org/bin/linux/x64/1.0/julia-1.0.3-linux-x86_64.tar.gz
</code></pre></div>
<p>Place the extracted files somewhere like a julia folder in your home dir.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">mkdir</span> ~/julia
<span class="nb">mv </span>julia-10.tar.gz ~/julia
<span class="nb">cd</span> ~/julia
<span class="nb">tar </span>xvf julia-10.tar.gz
</code></pre></div>
<p>Test Julia.
<code>bash
cd julia-1.0.3/bin
julia -e &#39;using InteractiveUtils; versioninfo()&#39;
</code></p>
<p>If you&#39;re still getting the old version, remove it.
<code>bash
sudo apt remove julia
</code></p>
<p>Update your PATH to have Julia&#39;s new location. Add this to your <code>.zshrc</code>, <code>.bashrc</code>, <code>.profile</code> or <code>.bash_profile</code>.
<code>bash
export PATH=~/julia/julia-1.0.3/bin:$PATH
</code></p>
<p>Validate your PATH.
<code>bash
echo $PATH
</code></p>
<p>Validate Julia works and is the expected version.
<code>bash
julia -e &#39;using InteractiveUtils; versioninfo()&#39;
</code></p>
<h4 id="setup-your-mxnet-julia-environment">Setup Your MXNet-Julia Environment</h4>
<p><strong>For each of the following environment variables, add the commands to your <code>.zshrc</code>, <code>.bashrc</code>, <code>.profile</code> or <code>.bash_profile</code> to make them persist.</strong></p>
<p>Create a <code>julia-depot</code> folder and environment variable.
<code>bash
mkdir julia-depot
export JULIA_DEPOT_PATH=$HOME/julia/julia-depot
</code></p>
<p>To use the Julia binding with an existing <code>libmxnet</code> installation, set the <code>MXNET_HOME</code> environment variable to the MXNet source root. For example:
<code>bash
export MXNET_HOME=$HOME/incubator-mxnet
</code></p>
<p>Now set the <code>LD_LIBRARY_PATH</code> environment variable to where <code>libmxnet.so</code> is found. If you can&#39;t find it, you might have skipped the building MXNet step. Go back and <a href="#build-the-shared-library">build MXNet</a> first. For example:
<code>bash
export LD_LIBRARY_PATH=$HOME/incubator-mxnet/lib:$LD_LIBRARY_PATH
</code></p>
<p>Verify the location of <code>libjemalloc.so</code> and set the <code>LD_PRELOAD</code> environment variable.
<code>bash
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so:$LD_PRELOAD
</code></p>
<p>With all of these updates, here&#39;s an example of what you might want to have in your <code>.zshrc</code>, <code>.bashrc</code>, <code>.profile</code> or <code>.bash_profile</code>.</p>
<div class="highlight"><pre><code class="language-" data-lang="">export PATH=$HOME/bin:$HOME/.local/bin:$HOME/julia/julia-1.0.3/bin:$PATH
export JULIA_DEPOT_PATH=$HOME/julia/julia-depot
export MXNET_HOME=$HOME/incubator-mxnet
export LD_LIBRARY_PATH=$HOME/incubator-mxnet/lib:$LD_LIBRARY_PATH
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so:$LD_PRELOAD
</code></pre></div>
<p>Install MXNet with Julia:</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash">julia <span class="nt">--color</span><span class="o">=</span><span class="nb">yes</span> <span class="nt">--project</span><span class="o">=</span>./ <span class="nt">-e</span> <span class="se">\</span>
<span class="s1">'using Pkg; \
Pkg.develop(PackageSpec(name="MXNet", path = joinpath(ENV["MXNET_HOME"], "julia")))'</span>
</code></pre></div>
<p>For more details about installing and using MXNet with Julia, see the <a href="/versions/1.6/api/julia">MXNet Julia documentation</a>.
<hr></p>
<h3 id="install-the-mxnet-package-for-perl">Install the MXNet Package for Perl</h3>
<p>Before you build MXNet for Perl from source code, you must complete <a 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"><pre><code class="language-bash" data-lang="bash"> <span class="nb">sudo </span>apt-get <span class="nb">install </span>libmouse-perl pdl cpanminus swig libgraphviz-perl
cpanm <span class="nt">-q</span> <span class="nt">-L</span> <span class="s2">"</span><span class="k">${</span><span class="nv">HOME</span><span class="k">}</span><span class="s2">/perl5"</span> Function::Parameters Hash::Ordered PDL::CCS
<span class="nv">MXNET_HOME</span><span class="o">=</span><span class="k">${</span><span class="nv">PWD</span><span class="k">}</span>
<span class="nb">export </span><span class="nv">LD_LIBRARY_PATH</span><span class="o">=</span><span class="k">${</span><span class="nv">MXNET_HOME</span><span class="k">}</span>/lib
<span class="nb">export </span><span class="nv">PERL5LIB</span><span class="o">=</span><span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/perl5/lib/perl5
<span class="nb">cd</span> <span class="k">${</span><span class="nv">MXNET_HOME</span><span class="k">}</span>/perl-package/AI-MXNetCAPI/
perl Makefile.PL <span class="nv">INSTALL_BASE</span><span class="o">=</span><span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/perl5
make <span class="nb">install
cd</span> <span class="k">${</span><span class="nv">MXNET_HOME</span><span class="k">}</span>/perl-package/AI-NNVMCAPI/
perl Makefile.PL <span class="nv">INSTALL_BASE</span><span class="o">=</span><span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/perl5
make <span class="nb">install
cd</span> <span class="k">${</span><span class="nv">MXNET_HOME</span><span class="k">}</span>/perl-package/AI-MXNet/
perl Makefile.PL <span class="nv">INSTALL_BASE</span><span class="o">=</span><span class="k">${</span><span class="nv">HOME</span><span class="k">}</span>/perl5
make <span class="nb">install</span>
</code></pre></div>
<p><hr></p>
<h3 id="install-the-mxnet-package-for-r">Install the MXNet Package for R</h3>
<p>Building <em>MXNet</em> from source is a 2 step process.
1. Build the <em>MXNet</em> core shared library, <code>libmxnet.so</code>, from source.
2. Build the R bindings.</p>
<h4 id="quick-mxnet-r-installation">Quick MXNet-R Installation</h4>
<p>You can quickly build MXNet-R with the following two scripts found in the <code>/docs/install</code> folder:</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash">git clone <span class="nt">--recursive</span> 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
</code></pre></div>
<p>Or you can go through a manual process described next.</p>
<h4 id="manual-mxnet-r-installation">Manual MXNet-R Installation</h4>
<p><strong>Minimum Requirements</strong>
1. <a href="https://gcc.gnu.org/gcc-4.8/">GCC 4.8</a> or later to compile C++ 11.
2. <a href="https://www.gnu.org/software/make/">GNU Make</a></p>
<p><br/></p>
<p><strong>Build the MXNet core shared library</strong></p>
<p><strong>Step 1</strong> Install build tools and git.
<code>bash
$ sudo apt-get update
$ sudo apt-get install -y build-essential git
</code></p>
<p><strong>Step 2</strong> Install OpenBLAS.</p>
<p><em>MXNet</em> uses <a href="https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms">BLAS</a> and <a 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 href="https://www.openblas.net/">OpenBLAS</a>, <a href="http://math-atlas.sourceforge.net/">ATLAS</a> and <a 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.
<code>bash
$ sudo apt-get install -y libopenblas-dev liblapack-dev
</code></p>
<p><strong>Step 3</strong> Install OpenCV.</p>
<p><em>MXNet</em> uses <a href="https://opencv.org/">OpenCV</a> for efficient image loading and augmentation operations.
<code>bash
$ sudo apt-get install -y libopencv-dev
</code></p>
<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">download links</a> for your desired MXNet version.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nv">$ </span>git clone <span class="nt">--recursive</span> https://github.com/apache/incubator-mxnet
<span class="nv">$ </span><span class="nb">cd </span>incubator-mxnet
<span class="nv">$ </span><span class="nb">echo</span> <span class="s2">"USE_OPENCV = 1"</span> <span class="o">&gt;&gt;</span> ./config.mk
<span class="nv">$ </span><span class="nb">echo</span> <span class="s2">"USE_BLAS = openblas"</span> <span class="o">&gt;&gt;</span> ./config.mk
<span class="nv">$ </span>make <span class="nt">-j</span> <span class="si">$(</span><span class="nb">nproc</span><span class="si">)</span>
</code></pre></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>make/config.mk</code>.</p>
<p><br/></p>
<p><strong>Step 5</strong> Make and install the MXNet-R bindings.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nv">$ </span>make rpkg
</code></pre></div>
<h4 id="verify-mxnet-r-installation">Verify MXNet-R Installation</h4>
<p>You can verify your MXNet-R installation as follows:</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">sudo</span> <span class="nt">-i</span> R
</code></pre></div>
<p>At the R prompt enter the following:</p>
<div class="highlight"><pre><code class="language-r" data-lang="r"><span class="n">library</span><span class="p">(</span><span class="n">mxnet</span><span class="p">)</span><span class="w">
</span><span class="n">a</span><span class="w"> </span><span class="o">&lt;-</span><span class="w"> </span><span class="n">mx.nd.ones</span><span class="p">(</span><span class="nf">c</span><span class="p">(</span><span class="m">2</span><span class="p">,</span><span class="m">3</span><span class="p">),</span><span class="w"> </span><span class="n">ctx</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">mx.cpu</span><span class="p">())</span><span class="w">
</span><span class="n">b</span><span class="w"> </span><span class="o">&lt;-</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="m">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="m">1</span><span class="w">
</span><span class="n">b</span><span class="w">
</span></code></pre></div>
<p>You should see the following output:</p>
<div class="highlight"><pre><code class="language-" data-lang=""> [,1] [,2] [,3]
[1,] 3 3 3
[2,] 3 3 3
&gt; quit()
</code></pre></div>
<p><hr></p>
<h3 id="install-the-mxnet-package-for-scala">Install the MXNet Package for Scala</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 href="scala_setup">MXNet-Scala Setup Instructions</a>.</p>
<p>If you use IntelliJ or a similar IDE, you may want to follow the <a href="/versions/1.6/api/scala/docs/tutorials/mxnet_scala_on_intellij">MXNet-Scala on IntelliJ tutorial</a> instead.
<hr></p>
<h3 id="install-the-mxnet-package-for-java">Install the MXNet Package for Java</h3>
<p>To use the MXNet-Java package, you can acquire the Maven package as a dependency.</p>
<p>Further information is in the <a href="java_setup">MXNet-Java Setup Instructions</a>.</p>
<p>If you use IntelliJ or a similar IDE, you may want to follow the <a href="/versions/1.6/api/java/docs/tutorials/mxnet_java_on_intellij">MXNet-Java on IntelliJ tutorial</a> instead.
<hr></p>
<h2 id="contributions">Contributions</h2>
<p>You are more than welcome to contribute easy installation scripts for other operating systems and programming languages. See the <a href="/versions/1.6/community/contribute">community contributions page</a> for further information.</p>
<h2 id="next-steps">Next Steps</h2>
<ul>
<li><a href="/versions/1.6/api">Tutorials</a></li>
<li><a href="/versions/1.6/api/faq/add_op_in_backend">How To</a></li>
<li><a href="/versions/1.6/api/architecture/overview">Architecture</a></li>
</ul>
<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>
</article>
</main><footer class="site-footer h-card">
<div class="wrapper">
<div class="row">
<div class="col-4">
<h4 class="footer-category-title">Resources</h4>
<ul class="contact-list">
<li><a href="/versions/1.6/community/contribute.html#mxnet-dev-communications">Mailing lists</a></li>
<li><a href="https://cwiki.apache.org/confluence/display/MXNET/Apache+MXNet+Home">Developer Wiki</a></li>
<li><a href="https://issues.apache.org/jira/projects/MXNET/issues">Jira Tracker</a></li>
<li><a href="https://github.com/apache/incubator-mxnet/labels/Roadmap">Github Roadmap</a></li>
<li><a href="https://discuss.mxnet.io">MXNet Discuss forum</a></li>
<li><a href="/versions/1.6/community/contribute.html">Contribute To MXNet</a></li>
</ul>
</div>
<div class="col-4"><ul class="social-media-list"><li><a href="https://github.com/apache/incubator-mxnet"><svg class="svg-icon"><use xlink:href="/versions/1.6/assets/minima-social-icons.svg#github"></use></svg> <span class="username">apache/incubator-mxnet</span></a></li><li><a href="https://www.twitter.com/apachemxnet"><svg class="svg-icon"><use xlink:href="/versions/1.6/assets/minima-social-icons.svg#twitter"></use></svg> <span class="username">apachemxnet</span></a></li><li><a href="https://youtube.com/apachemxnet"><svg class="svg-icon"><use xlink:href="/versions/1.6/assets/minima-social-icons.svg#youtube"></use></svg> <span class="username">apachemxnet</span></a></li></ul>
</div>
<div class="col-4 footer-text">
<p>A flexible and efficient library for deep learning.</p>
</div>
</div>
</div>
</footer>
<footer class="site-footer2">
<div class="wrapper">
<div class="row">
<div class="col-3">
<img src="/versions/1.6/assets/img/apache_incubator_logo.png" class="footer-logo col-2">
</div>
<div class="footer-bottom-warning col-9">
<p>Apache MXNet is an effort undergoing incubation at The Apache Software Foundation (ASF), <span
style="font-weight:bold">sponsored by the <i>Apache Incubator</i></span>. 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>
</footer>
</body>
</html>