blob: 17eaaaff88c4eb75e0eea36c7cb0d6231f007676 [file] [log] [blame]
<!DOCTYPE html>
<!---
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.
-->
<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="/versions/1.9.1/assets/img/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/versions/1.9.1/get_started/ubuntu_setup" />
<meta property="og:url" content="https://mxnet.apache.org/versions/1.9.1/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/versions/1.9.1/get_started/ubuntu_setup","@context":"https://schema.org"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="/versions/1.9.1/assets/docsearch.min.css" /><link rel="stylesheet" href="/versions/1.9.1/assets/main.css"><link type="application/atom+xml" rel="alternate" href="https://mxnet.apache.org/versions/1.9.1/feed.xml" title="Apache MXNet" /><!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
/* We explicitly disable cookie tracking to avoid privacy issues */
_paq.push(['disableCookies']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.apache.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '23']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
<script src="/versions/1.9.1/assets/js/jquery-3.3.1.min.js"></script>
<script src="/versions/1.9.1/assets/js/docsearch.min.js"></script><script src="/versions/1.9.1/assets/js/globalSearch.js" defer></script>
<script src="/versions/1.9.1/assets/js/clipboard.js" defer></script>
<script src="/versions/1.9.1/assets/js/copycode.js" defer></script></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.9.1/"><img
src="/versions/1.9.1/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="gs-search-border">
<div id="gs-search-icon"></div>
<form id="global-search-form">
<input id="global-search" type="text" title="Search" placeholder="Search" />
<div id="global-search-dropdown-container">
<button class="gs-current-version btn" type="button" data-toggle="dropdown">
<span id="gs-current-version-label">1.9.1</span>
<svg class="gs-dropdown-caret" viewBox="0 0 32 32" class="icon icon-caret-bottom" aria-hidden="true">
<path class="dropdown-caret-path" d="M24 11.305l-7.997 11.39L8 11.305z"></path>
</svg>
</button>
<ul class="gs-opt-group gs-version-dropdown">
<li class="gs-opt gs-versions">master</li>
<li class="gs-opt gs-versions active">1.9.1</li>
<li class="gs-opt gs-versions">1.8.0</li>
<li class="gs-opt gs-versions">1.7.0</li>
<li class="gs-opt gs-versions">1.6.0</li>
<li class="gs-opt gs-versions">1.5.0</li>
<li class="gs-opt gs-versions">1.4.1</li>
<li class="gs-opt gs-versions">1.3.1</li>
<li class="gs-opt gs-versions">1.2.1</li>
<li class="gs-opt gs-versions">1.1.0</li>
<li class="gs-opt gs-versions">1.0.0</li>
<li class="gs-opt gs-versions">0.12.1</li>
<li class="gs-opt gs-versions">0.11.0</li>
</ul>
</div>
<span id="global-search-close">x</span>
</form>
</div>
<div class="trigger">
<div id="global-search-mobile-border">
<div id="gs-search-icon-mobile"></div>
<input id="global-search-mobile" placeholder="Search..." type="text"/>
<div id="global-search-dropdown-container-mobile">
<button class="gs-current-version-mobile btn" type="button" data-toggle="dropdown">
<svg class="gs-dropdown-caret" viewBox="0 0 32 32" class="icon icon-caret-bottom" aria-hidden="true">
<path class="dropdown-caret-path" d="M24 11.305l-7.997 11.39L8 11.305z"></path>
</svg>
</button>
<ul class="gs-opt-group gs-version-dropdown-mobile">
<li class="gs-opt gs-versions">master</li>
<li class="gs-opt gs-versions active">1.9.1</li>
<li class="gs-opt gs-versions">1.8.0</li>
<li class="gs-opt gs-versions">1.7.0</li>
<li class="gs-opt gs-versions">1.6.0</li>
<li class="gs-opt gs-versions">1.5.0</li>
<li class="gs-opt gs-versions">1.4.1</li>
<li class="gs-opt gs-versions">1.3.1</li>
<li class="gs-opt gs-versions">1.2.1</li>
<li class="gs-opt gs-versions">1.1.0</li>
<li class="gs-opt gs-versions">1.0.0</li>
<li class="gs-opt gs-versions">0.12.1</li>
<li class="gs-opt gs-versions">0.11.0</li>
</ul>
</div>
</div>
<a class="page-link" href="/versions/1.9.1/get_started">Get Started</a>
<a class="page-link" href="/versions/1.9.1/features">Features</a>
<a class="page-link" href="/versions/1.9.1/ecosystem">Ecosystem</a>
<a class="page-link" href="/versions/1.9.1/api">Docs & Tutorials</a>
<a class="page-link" href="/versions/1.9.1/trusted_by">Trusted By</a>
<a class="page-link" href="https://github.com/apache/mxnet">GitHub</a>
<div class="dropdown" style="min-width:100px">
<span class="dropdown-header">Apache
<svg class="dropdown-caret" viewBox="0 0 32 32" class="icon icon-caret-bottom" aria-hidden="true"><path class="dropdown-caret-path" d="M24 11.305l-7.997 11.39L8 11.305z"></path></svg>
</span>
<div class="dropdown-content" style="min-width:250px">
<a href="https://www.apache.org/foundation/">Apache Software Foundation</a>
<a href="https://www.apache.org/licenses/">License</a>
<a href="/versions/1.9.1/api/faq/security.html">Security</a>
<a href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy</a>
<a href="https://www.apache.org/events/current-event">Events</a>
<a href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a>
<a href="https://www.apache.org/foundation/thanks.html">Thanks</a>
</div>
</div>
<div class="dropdown">
<span class="dropdown-header">1.9.1
<svg class="dropdown-caret" viewBox="0 0 32 32" class="icon icon-caret-bottom" aria-hidden="true"><path class="dropdown-caret-path" d="M24 11.305l-7.997 11.39L8 11.305z"></path></svg>
</span>
<div class="dropdown-content">
<a href="/">master</a>
<a class="dropdown-option-active" href="/versions/1.9.1/">1.9.1</a>
<a href="/versions/1.8.0/">1.8.0</a>
<a href="/versions/1.7.0/">1.7.0</a>
<a href="/versions/1.6.0/">1.6.0</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.9.1/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-from-source-on-ubuntu">Installing MXNet from source on Ubuntu</h1>
<p>The following installation instructions are for building MXNet from source on
computers running <strong>Ubuntu 16.04</strong> or higher. For instructions to build MXNet
from source on other platforms, see the general <a href="build_from_source">Build From Source
guide</a>.</p>
<p>Instead of building from source, you can install a binary version of MXNet. For
that, please follow the information at <a href="get_started">Get Started</a>.</p>
<p>Building MXNet from source 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.</li>
</ol>
<h2 id="contents">Contents</h2>
<ul>
<li><a href="#cuda-dependencies">CUDA Dependencies</a></li>
<li><a href="#build-mxnet-from-source">Build the MXNet shared library from source</a></li>
<li><a href="#installing-language-packages-for-mxnet">Install 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="build-the-mxnet-shared-library-from-source">Build the MXNet shared library from source</h2>
<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.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">sudo </span>apt-get update
<span class="nb">sudo </span>apt-get <span class="nb">install</span> <span class="nt">-y</span> build-essential git ninja-build ccache libopenblas-dev libopencv-dev cmake
</code></pre></div>
<p>Instead of <code>libopenblas-dev</code> you may also choose a different math library.
Further information is provided in the source guide&#39;s <a href="build_from_source#math-library-selection">Math Library
Selection</a> section.</p>
<p><code>libopencv-dev</code> is an optional dependency. You can delete it from above <code>apt-get
install</code> line and build MXNet without OpenCV support by setting <code>USE_OPENCV</code> to
<code>OFF</code> in the configuration file described below.</p>
<p>Note: CMake 3.13 or higher is required. If you are running an older version of
CMake, you will see an error message like <code>CMake 3.13 or higher is required. You
are running version 3.10.2</code> during Step 3. In that case please update CMake on
your system. You can download and install latest CMake from <a href="https://cmake.org">https://cmake.org</a> or
via <code>pip3</code> with <code>pip3 install --user --upgrade &quot;cmake&gt;=3.13.2&quot;</code>. If <code>pip3</code> is
not available on your system, you can install it via <code>sudo apt-get install -y
python3-pip</code>. After installing cmake with <code>pip3</code>, it is usually available at
<code>~/.local/bin/cmake</code> or directly as <code>cmake</code>.</p>
<p><strong>Step 2:</strong> Download MXNet sources and configure</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/mxnet.git mxnet
<span class="nb">cd </span>mxnet
<span class="nb">cp </span>config/linux.cmake config.cmake <span class="c"># or config/linux_gpu.cmake for build with CUDA</span>
</code></pre></div>
<p>Please edit the config.cmake file based on your needs. The file contains a
series of <code>set(name value CACHE TYPE &quot;Description&quot;)</code> entries. You can change the
values of the respective <code>value</code>.</p>
<p>For a GPU-enabled build make sure you have installed the <a href="#cuda-dependencies">CUDA dependencies
first</a>). When building a GPU-enabled build on a machine
without GPU, MXNet build can&#39;t autodetect your GPU architecture and will target
all available GPU architectures. Please set the <code>MXNET_CUDA_ARCH</code> variable in
<code>config.cmake</code> to your desired cuda architecture to speed up the build.</p>
<p>To (optionally) build with MKL math library, please install MKL first based on
the guide in <a href="build_from_source#math-library-selection">Math Library Selection</a>.</p>
<p><strong>Step 3:</strong> Build MXNet core shared library.</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 ..
cmake <span class="nt">--build</span> <span class="nb">.</span>
</code></pre></div>
<p>Specify <code>cmake --build . --parallel N</code> to set the number of parallel compilation
jobs. Default is derived from CPUs available.</p>
<p>After a successful build, you will find the <code>libmxnet.so</code> in the <code>build</code> folder
in your MXNet project root. <code>libmxnet.so</code> is required to install language
bindings described in the next section.</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="nb">cd </span>python
pip <span class="nb">install</span> <span class="nt">--user</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">pip <span class="nb">install</span> <span class="nt">--user</span> <span class="nv">graphviz</span><span class="o">==</span>0.8.4 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/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.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">cd </span>julia-1.0.3/bin
julia <span class="nt">-e</span> <span class="s1">'using InteractiveUtils; versioninfo()'</span>
</code></pre></div>
<p>If you&#39;re still getting the old version, remove it.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">sudo </span>apt remove julia
</code></pre></div>
<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>.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">export </span><span class="nv">PATH</span><span class="o">=</span>~/julia/julia-1.0.3/bin:<span class="nv">$PATH</span>
</code></pre></div>
<p>Validate your PATH.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">echo</span> <span class="nv">$PATH</span>
</code></pre></div>
<p>Validate Julia works and is the expected version.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash">julia <span class="nt">-e</span> <span class="s1">'using InteractiveUtils; versioninfo()'</span>
</code></pre></div>
<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.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">mkdir </span>julia-depot
<span class="nb">export </span><span class="nv">JULIA_DEPOT_PATH</span><span class="o">=</span><span class="nv">$HOME</span>/julia/julia-depot
</code></pre></div>
<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:</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">export </span><span class="nv">MXNET_HOME</span><span class="o">=</span><span class="nv">$HOME</span>/mxnet
</code></pre></div>
<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:</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">export </span><span class="nv">LD_LIBRARY_PATH</span><span class="o">=</span><span class="nv">$HOME</span>/mxnet/lib:<span class="nv">$LD_LIBRARY_PATH</span>
</code></pre></div>
<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/mxnet
export LD_LIBRARY_PATH=$HOME/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.9.1/api/julia">MXNet Julia documentation</a>.</p>
<p><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>Before you build MXNet for R from source code, you must complete
<a href="#build-the-shared-library">building the shared library</a>.</p>
<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 R, cran-devtools and dependencies</p>
<p>To install R and the devtools, run</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nb">sudo </span>apt-get update
<span class="nb">sudo </span>apt-get <span class="nb">install</span> <span class="nt">-y</span> r-base-core r-cran-devtools libcairo2-dev libxml2-dev
</code></pre></div>
<p><code>libxml2-dev</code> is required for the <code>roxygen2</code> dependency and <code>libcairo2-dev</code> is
required for the suggested <code>imager</code> dependency.</p>
<p>To generate documentation, it is also required to install <code>roxygen2</code>.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash">R
<span class="o">&gt;</span> install.packages<span class="o">(</span><span class="s2">"roxygen2"</span><span class="o">)</span>
<span class="o">&gt;</span> Would you like to use a personal library instead? <span class="o">(</span>y/n<span class="o">)</span> y
<span class="o">&gt;</span> Would you like to create a personal library ... to <span class="nb">install </span>packages into? <span class="o">(</span>y/n<span class="o">)</span> y
</code></pre></div>
<p>Note: To successfully complete the next step, you need a personal R library. If
you were able to run <code>install.packages(&quot;roxygen2&quot;)</code> above, you either had
already, or you have successfully created a personal library just now.</p>
<p><strong>Step 2</strong> Make and install the MXNet-R bindings.</p>
<div class="highlight"><pre><code class="language-bash" data-lang="bash">make <span class="nt">-f</span> R-package/Makefile 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">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.9.1/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.9.1/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.9.1/community/contribute">community contributions page</a> for further information.</p>
<h2 id="next-steps">Next Steps</h2>
<ul>
<li><a href="/versions/1.9.1/api">Tutorials</a></li>
<li><a href="/versions/1.9.1/api/faq/add_op_in_backend">How To</a></li>
<li><a href="/versions/1.9.1/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.9.1/community/contribute#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/mxnet/labels/Roadmap">Github Roadmap</a></li>
<li><a href="https://medium.com/apache-mxnet">Blog</a></li>
<li><a href="https://discuss.mxnet.io">Forum</a></li>
<li><a href="/versions/1.9.1/community/contribute">Contribute</a></li>
</ul>
</div>
<div class="col-4"><ul class="social-media-list"><li><a href="https://github.com/apache/mxnet"><svg class="svg-icon"><use xlink:href="/versions/1.9.1/assets/minima-social-icons.svg#github"></use></svg> <span class="username">apache/mxnet</span></a></li><li><a href="https://www.twitter.com/apachemxnet"><svg class="svg-icon"><use xlink:href="/versions/1.9.1/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.9.1/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.9.1/assets/img/asf_logo.svg" class="footer-logo col-2">
</div>
<div class="footer-bottom-warning col-9">
</p><p>"Copyright © 2017-2022, The Apache Software Foundation. Licensed under the Apache License, Version 2.0. 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>