| <!DOCTYPE html> |
| |
| <html lang="en"> |
| <head> |
| <meta charset="utf-8"/> |
| <meta content="IE=edge" http-equiv="X-UA-Compatible"/> |
| <meta content="width=device-width, initial-scale=1" name="viewport"/> |
| <meta content="MXNet on the Cloud" property="og:title"> |
| <meta content="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/og-logo.png" property="og:image"> |
| <meta content="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/og-logo.png" property="og:image:secure_url"> |
| <meta content="MXNet on the Cloud" property="og:description"/> |
| <title>MXNet on the Cloud — mxnet documentation</title> |
| <link crossorigin="anonymous" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" rel="stylesheet"/> |
| <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/> |
| <link href="../_static/basic.css" rel="stylesheet" type="text/css"> |
| <link href="../_static/pygments.css" rel="stylesheet" type="text/css"> |
| <link href="../_static/mxnet.css" rel="stylesheet" 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 src="https://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script> |
| <script src="../_static/underscore.js" type="text/javascript"></script> |
| <script src="../_static/searchtools_custom.js" type="text/javascript"></script> |
| <script src="../_static/doctools.js" type="text/javascript"></script> |
| <script src="../_static/selectlang.js" type="text/javascript"></script> |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></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 href="../genindex.html" rel="index" title="Index"> |
| <link href="../search.html" rel="search" title="Search"/> |
| <link href="index.html" rel="up" title="MXNet FAQ"/> |
| <link href="develop_and_hack.html" rel="next" title="Develop and Hack MXNet"/> |
| <link href="caffe.html" rel="prev" title="How to | Convert from Caffe to MXNet"/> |
| <link href="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-icon.png" rel="icon" type="image/png"/> |
| </link></link></link></meta></meta></meta></head> |
| <body background="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-background-compressed.jpeg" role="document"> |
| <div class="content-block"><div class="navbar navbar-fixed-top"> |
| <div class="container" id="navContainer"> |
| <div class="innder" id="header-inner"> |
| <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 class="dropdown-toggle" data-toggle="dropdown" href="#" role="button"><span aria-hidden="true" class="glyphicon glyphicon-plus"></span></a> |
| <ul class="dropdown-menu dropdown-menu-right" id="plusMenu"></ul> |
| </div> |
| <div id="search-input-wrap"> |
| <form action="../search.html" autocomplete="off" class="" method="get" role="search"> |
| <div class="form-group inner-addon left-addon"> |
| <i class="glyphicon glyphicon-search"></i> |
| <input class="form-control" name="q" placeholder="Search" type="text"/> |
| </div> |
| <input name="check_keywords" type="hidden" value="yes"> |
| <input name="area" type="hidden" value="default"/> |
| </input></form> |
| <div id="search-preview"></div> |
| </div> |
| <div id="searchIcon"> |
| <span aria-hidden="true" class="glyphicon glyphicon-search"></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 aria-label="main navigation" class="sphinxsidebar leftsidebar" role="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="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="../install/index.html">Installing MXNet</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../install/index.html#nvidia-jetson-tx-family">Nvidia Jetson TX family</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../install/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="mxnet-on-the-cloud"> |
| <span id="mxnet-on-the-cloud"></span><h1>MXNet on the Cloud<a class="headerlink" href="#mxnet-on-the-cloud" title="Permalink to this headline">¶</a></h1> |
| <p>Deep learning can require extremely powerful hardware, often for unpredictable durations of time. |
| Moreover, <em>MXNet</em> can benefit from both multiple GPUs and multiple machines. |
| Accordingly, cloud computing, as offered by AWS and others, |
| is especially well suited to training deep learning models. |
| Using AWS, we can rapidly fire up multiple machines with multiple GPUs each at will |
| and maintain the resources for precisely the amount of time needed.</p> |
| <div class="section" id="set-up-an-aws-gpu-cluster-from-scratch"> |
| <span id="set-up-an-aws-gpu-cluster-from-scratch"></span><h2>Set Up an AWS GPU Cluster from Scratch<a class="headerlink" href="#set-up-an-aws-gpu-cluster-from-scratch" title="Permalink to this headline">¶</a></h2> |
| <p>In this document, we provide a step-by-step guide that will teach you |
| how to set up an AWS cluster with <em>MXNet</em>. We show how to:</p> |
| <ul class="simple"> |
| <li><a class="reference external" href="#use-amazon-s3-to-host-data">Use Amazon S3 to host data</a></li> |
| <li><a class="reference external" href="#set-up-an-ec2-gpu-instance">Set up an EC2 GPU instance with all dependencies installed</a></li> |
| <li><a class="reference external" href="#build-and-run-mxnet-on-a-gpu-instance">Build and run MXNet on a single computer</a></li> |
| <li><a class="reference external" href="#set-up-an-ec2-gpu-cluster-for-distributed-training">Set up an EC2 GPU cluster for distributed training</a></li> |
| </ul> |
| <div class="section" id="use-amazon-s3-to-host-data"> |
| <span id="use-amazon-s3-to-host-data"></span><h3>Use Amazon S3 to Host Data<a class="headerlink" href="#use-amazon-s3-to-host-data" title="Permalink to this headline">¶</a></h3> |
| <p>Amazon S3 provides distributed data storage which proves especially convenient for hosting large datasets. |
| To use S3, you need <a class="reference external" href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html">AWS credentials</a>, |
| including an <code class="docutils literal"><span class="pre">ACCESS_KEY_ID</span></code> and a <code class="docutils literal"><span class="pre">SECRET_ACCESS_KEY</span></code>.</p> |
| <p>To use <em>MXNet</em> with S3, set the environment variables <code class="docutils literal"><span class="pre">AWS_ACCESS_KEY_ID</span></code> and |
| <code class="docutils literal"><span class="pre">AWS_SECRET_ACCESS_KEY</span></code> by adding the following two lines in |
| <code class="docutils literal"><span class="pre">~/.bashrc</span></code> (replacing the strings with the correct ones):</p> |
| <div class="highlight-bash"><div class="highlight"><pre><span></span><span class="nb">export</span> <span class="nv">AWS_ACCESS_KEY_ID</span><span class="o">=</span>AKIAIOSFODNN7EXAMPLE |
| <span class="nb">export</span> <span class="nv">AWS_SECRET_ACCESS_KEY</span><span class="o">=</span>wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY |
| </pre></div> |
| </div> |
| <p>There are several ways to upload data to S3. One simple way is to use |
| <a class="reference external" href="http://s3tools.org/s3cmd">s3cmd</a>. For example:</p> |
| <div class="highlight-bash"><div class="highlight"><pre><span></span>wget http://data.mxnet.io/mxnet/data/mnist.zip |
| unzip mnist.zip <span class="o">&&</span> s3cmd put t*-ubyte s3://dmlc/mnist/ |
| </pre></div> |
| </div> |
| </div> |
| <div class="section" id="use-pre-installed-ec2-gpu-instance"> |
| <span id="use-pre-installed-ec2-gpu-instance"></span><h3>Use Pre-installed EC2 GPU Instance<a class="headerlink" href="#use-pre-installed-ec2-gpu-instance" title="Permalink to this headline">¶</a></h3> |
| <p>The <a class="reference external" href="https://aws.amazon.com/marketplace/pp/B01M0AXXQB?qid=1475211685369&sr=0-1&ref_=srh_res_product_title">Deep Learning AMI</a> is an Amazon Linux image |
| supported and maintained by Amazon Web Services for use on Amazon Elastic Compute Cloud (Amazon EC2). |
| It contains <a class="reference external" href="https://github.com/dmlc/mxnet">MXNet-v0.9.3 tag</a> and the necessary components to get going with deep learning, |
| including Nvidia drivers, CUDA, cuDNN, Anaconda, Python2 and Python3.The AMI IDs are the following:</p> |
| <ul class="simple"> |
| <li>us-east-1: ami-e7c96af1</li> |
| <li>us-west-2: ami-dfb13ebf</li> |
| <li>eu-west-1: ami-6e5d6808</li> |
| </ul> |
| <p>Now you can launch <em>MXNet</em> directly on an EC2 GPU instance.You can also use <a class="reference external" href="http://jupyter.org">Jupyter</a> notebook on EC2 machine. |
| Here is a <a class="reference external" href="https://github.com/dmlc/mxnet-notebooks">good tutorial</a> |
| on how to connect to a Jupyter notebook running on an EC2 instance.</p> |
| </div> |
| <div class="section" id="set-up-an-ec2-gpu-instance-from-scratch"> |
| <span id="set-up-an-ec2-gpu-instance-from-scratch"></span><h3>Set Up an EC2 GPU Instance from Scratch<a class="headerlink" href="#set-up-an-ec2-gpu-instance-from-scratch" title="Permalink to this headline">¶</a></h3> |
| <p><em>MXNet</em> requires the following libraries:</p> |
| <ul class="simple"> |
| <li>C++ compiler with C++11 support, such as <code class="docutils literal"><span class="pre">gcc</span> <span class="pre">>=</span> <span class="pre">4.8</span></code></li> |
| <li><code class="docutils literal"><span class="pre">CUDA</span></code> (<code class="docutils literal"><span class="pre">CUDNN</span></code> in optional) for GPU linear algebra</li> |
| <li><code class="docutils literal"><span class="pre">BLAS</span></code> (cblas, open-blas, atblas, mkl, or others) for CPU linear algebra</li> |
| <li><code class="docutils literal"><span class="pre">opencv</span></code> for image augmentations</li> |
| <li><code class="docutils literal"><span class="pre">curl</span></code> and <code class="docutils literal"><span class="pre">openssl</span></code> for the ability to read/write to Amazon S3</li> |
| </ul> |
| <p>Installing <code class="docutils literal"><span class="pre">CUDA</span></code> on EC2 instances requires some effort. Caffe has a good |
| <a class="reference external" href="https://github.com/BVLC/caffe/wiki/Install-Caffe-on-EC2-from-scratch-(Ubuntu,-CUDA-7,-cuDNN-3)">tutorial</a> |
| on how to install CUDA 7.0 on Ubuntu 14.04.</p> |
| <p><strong><em>Note:</em></strong> We tried CUDA 7.5 on Nov 7, 2015, but found it problematic.</p> |
| <p>You can install the rest using the package manager. For example, on Ubuntu:</p> |
| <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">apt</span><span class="o">-</span><span class="n">get</span> <span class="n">update</span> |
| <span class="n">sudo</span> <span class="n">apt</span><span class="o">-</span><span class="n">get</span> <span class="n">install</span> <span class="o">-</span><span class="n">y</span> <span class="n">build</span><span class="o">-</span><span class="n">essential</span> <span class="n">git</span> <span class="n">libcurl4</span><span class="o">-</span><span class="n">openssl</span><span class="o">-</span><span class="n">dev</span> <span class="n">libatlas</span><span class="o">-</span><span class="n">base</span><span class="o">-</span><span class="n">dev</span> <span class="n">libopencv</span><span class="o">-</span><span class="n">dev</span> <span class="n">python</span><span class="o">-</span><span class="n">numpy</span> |
| </pre></div> |
| </div> |
| <p>The Amazon Machine Image (AMI) <a class="reference external" href="https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:ami=ami-12fd8178">ami-12fd8178</a> has the packages listed above installed.</p> |
| </div> |
| <div class="section" id="build-and-run-mxnet-on-a-gpu-instance"> |
| <span id="build-and-run-mxnet-on-a-gpu-instance"></span><h3>Build and Run MXNet on a GPU Instance<a class="headerlink" href="#build-and-run-mxnet-on-a-gpu-instance" title="Permalink to this headline">¶</a></h3> |
| <p>The following commands build <em>MXNet</em> with CUDA/CUDNN, Amazon S3, and distributed |
| training.</p> |
| <div class="highlight-bash"><div class="highlight"><pre><span></span>git clone --recursive https://github.com/dmlc/mxnet |
| <span class="nb">cd</span> mxnet<span class="p">;</span> cp make/config.mk . |
| <span class="nb">echo</span> <span class="s2">"USE_CUDA=1"</span> >>config.mk |
| <span class="nb">echo</span> <span class="s2">"USE_CUDA_PATH=/usr/local/cuda"</span> >>config.mk |
| <span class="nb">echo</span> <span class="s2">"USE_CUDNN=1"</span> >>config.mk |
| <span class="nb">echo</span> <span class="s2">"USE_BLAS=atlas"</span> >> config.mk |
| <span class="nb">echo</span> <span class="s2">"USE_DIST_KVSTORE = 1"</span> >>config.mk |
| <span class="nb">echo</span> <span class="s2">"USE_S3=1"</span> >>config.mk |
| make -j<span class="k">$(</span>nproc<span class="k">)</span> |
| </pre></div> |
| </div> |
| <p>To test whether everything is installed properly, we can try training a convolutional neural network (CNN) on the MNIST dataset using a GPU:</p> |
| <div class="highlight-bash"><div class="highlight"><pre><span></span>python example/image-classification/train_mnist.py |
| </pre></div> |
| </div> |
| <p>If you’ve placed the MNIST data on <code class="docutils literal"><span class="pre">s3://dmlc/mnist</span></code>, you can read the data stored on Amazon S3 directly with the following command:</p> |
| <div class="highlight-bash"><div class="highlight"><pre><span></span>sed -i.bak <span class="s2">"s!data_dir = 'data'!data_dir = 's3://dmlc/mnist'!"</span> example/image-classification/train_mnist.py |
| </pre></div> |
| </div> |
| <p><strong><em>Note:</em></strong> You can use <code class="docutils literal"><span class="pre">sudo</span> <span class="pre">ln</span> <span class="pre">/dev/null</span> <span class="pre">/dev/raw1394</span></code> to fix the opencv error <code class="docutils literal"><span class="pre">libdc1394</span> <span class="pre">error:</span> <span class="pre">Failed</span> <span class="pre">to</span> <span class="pre">initialize</span> <span class="pre">libdc1394</span></code>.</p> |
| </div> |
| <div class="section" id="set-up-an-ec2-gpu-cluster-for-distributed-training"> |
| <span id="set-up-an-ec2-gpu-cluster-for-distributed-training"></span><h3>Set Up an EC2 GPU Cluster for Distributed Training<a class="headerlink" href="#set-up-an-ec2-gpu-cluster-for-distributed-training" title="Permalink to this headline">¶</a></h3> |
| <p>A cluster consists of multiple computers. |
| You can use one computer with <em>MXNet</em> installed as the root computer for submitting jobs,and then launch several |
| slave computers to run the jobs. For example, launch multiple instances using an |
| AMI, e.g., |
| <a class="reference external" href="https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:ami=ami-12fd8178">ami-12fd8178</a>, |
| with dependencies installed. There are two options:</p> |
| <ul class="simple"> |
| <li>Make all slaves’ ports accessible (same for the root) by setting type: All TCP, |
| Source: Anywhere in Configure Security Group.</li> |
| <li>Use the same <code class="docutils literal"><span class="pre">pem</span></code> as the root computer to access all slave computers, and |
| then copy the <code class="docutils literal"><span class="pre">pem</span></code> file into the root computer’s <code class="docutils literal"><span class="pre">~/.ssh/id_rsa</span></code>. If you do this, all slave computers can be accessed with SSH from the root.</li> |
| </ul> |
| <p>Now, run the CNN on multiple computers. Assume that we are on a working |
| directory of the root computer, such as <code class="docutils literal"><span class="pre">~/train</span></code>, and MXNet is built as <code class="docutils literal"><span class="pre">~/mxnet</span></code>.</p> |
| <ol class="simple"> |
| <li>Pack the <em>MXNet</em> Python library into this working directory for easy |
| synchronization:</li> |
| </ol> |
| <div class="highlight-bash"><div class="highlight"><pre><span></span> cp -r ~/mxnet/python/mxnet . |
| cp ~/mxnet/lib/libmxnet.so mxnet/ |
| </pre></div> |
| </div> |
| <p>And then copy the training program:</p> |
| <div class="highlight-bash"><div class="highlight"><pre><span></span> cp ~/mxnet/example/image-classification/*.py . |
| cp -r ~/mxnet/example/image-classification/common . |
| </pre></div> |
| </div> |
| <ol class="simple"> |
| <li>Prepare a host file with all slaves private IPs. For example, <code class="docutils literal"><span class="pre">cat</span> <span class="pre">hosts</span></code>:</li> |
| </ol> |
| <div class="highlight-bash"><div class="highlight"><pre><span></span> <span class="m">172</span>.30.0.172 |
| <span class="m">172</span>.30.0.171 |
| </pre></div> |
| </div> |
| <ol class="simple"> |
| <li>Assuming that there are two computers, train the CNN using two workers:</li> |
| </ol> |
| <div class="highlight-bash"><div class="highlight"><pre><span></span> ../../tools/launch.py -n <span class="m">2</span> -H hosts --sync-dir /tmp/mxnet python train_mnist.py --kv-store dist_sync |
| </pre></div> |
| </div> |
| <p><strong><em>Note:</em></strong> Sometimes the jobs linger at the slave computers even though you’ve pressed <code class="docutils literal"><span class="pre">Ctrl-c</span></code> |
| at the root node. To terminate them, use the following command:</p> |
| <div class="highlight-bash"><div class="highlight"><pre><span></span>cat hosts <span class="p">|</span> xargs -I<span class="o">{}</span> ssh -o <span class="nv">StrictHostKeyChecking</span><span class="o">=</span>no <span class="o">{}</span> <span class="s1">'uname -a; pgrep python | xargs kill -9'</span> |
| </pre></div> |
| </div> |
| <p><strong><em>Note:</em></strong> The preceding example is very simple to train and therefore isn’t a good |
| benchmark for distributed training. Consider using other <a class="reference external" href="https://github.com/dmlc/mxnet/tree/master/example/image-classification">examples</a>.</p> |
| </div> |
| <div class="section" id="more-options"> |
| <span id="more-options"></span><h3>More Options<a class="headerlink" href="#more-options" title="Permalink to this headline">¶</a></h3> |
| <div class="section" id="use-multiple-data-shards"> |
| <span id="use-multiple-data-shards"></span><h4>Use Multiple Data Shards<a class="headerlink" href="#use-multiple-data-shards" title="Permalink to this headline">¶</a></h4> |
| <p>It is common to pack a dataset into multiple files, especially when working in a distributed environment. |
| <em>MXNet</em> supports direct loading from multiple data shards. |
| Put all of the record files into a folder, and point the data path to the folder.</p> |
| </div> |
| <div class="section" id="use-yarn-and-sge"> |
| <span id="use-yarn-and-sge"></span><h4>Use YARN and SGE<a class="headerlink" href="#use-yarn-and-sge" title="Permalink to this headline">¶</a></h4> |
| <p>Although using SSH can be simple when you don’t have a cluster scheduling framework, |
| <em>MXNet</em> is designed to be portable to various platforms.We provide scripts available in <a class="reference external" href="https://github.com/dmlc/dmlc-core/tree/master/tracker">tracker</a> |
| to allow running on other cluster frameworks, including Hadoop (YARN) and SGE. |
| We welcome contributions from the community of examples of running <em>MXNet</em> on your favorite distributed platform.</p> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div aria-label="main navigation" class="sphinxsidebar rightsidebar" role="navigation"> |
| <div class="sphinxsidebarwrapper"> |
| <h3><a href="../index.html">Table Of Contents</a></h3> |
| <ul> |
| <li><a class="reference internal" href="#">MXNet on the Cloud</a><ul> |
| <li><a class="reference internal" href="#set-up-an-aws-gpu-cluster-from-scratch">Set Up an AWS GPU Cluster from Scratch</a><ul> |
| <li><a class="reference internal" href="#use-amazon-s3-to-host-data">Use Amazon S3 to Host Data</a></li> |
| <li><a class="reference internal" href="#use-pre-installed-ec2-gpu-instance">Use Pre-installed EC2 GPU Instance</a></li> |
| <li><a class="reference internal" href="#set-up-an-ec2-gpu-instance-from-scratch">Set Up an EC2 GPU Instance from Scratch</a></li> |
| <li><a class="reference internal" href="#build-and-run-mxnet-on-a-gpu-instance">Build and Run MXNet on a GPU Instance</a></li> |
| <li><a class="reference internal" href="#set-up-an-ec2-gpu-cluster-for-distributed-training">Set Up an EC2 GPU Cluster for Distributed Training</a></li> |
| <li><a class="reference internal" href="#more-options">More Options</a><ul> |
| <li><a class="reference internal" href="#use-multiple-data-shards">Use Multiple Data Shards</a></li> |
| <li><a class="reference internal" href="#use-yarn-and-sge">Use YARN and SGE</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </div><div class="footer"> |
| <div class="section-disclaimer"> |
| <div class="container"> |
| <div> |
| <img height="60" src="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/apache_incubator_logo.png"/> |
| <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 crossorigin="anonymous" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> |
| <script src="../_static/js/sidebar.js" type="text/javascript"></script> |
| <script src="../_static/js/search.js" type="text/javascript"></script> |
| <script src="../_static/js/navbar.js" type="text/javascript"></script> |
| <script src="../_static/js/clipboard.min.js" type="text/javascript"></script> |
| <script src="../_static/js/copycode.js" type="text/javascript"></script> |
| <script src="../_static/js/page.js" type="text/javascript"></script> |
| <script src="../_static/js/docversion.js" type="text/javascript"></script> |
| <script type="text/javascript"> |
| $('body').ready(function () { |
| $('body').css('visibility', 'visible'); |
| }); |
| </script> |
| </body> |
| </html> |