blob: 68c8884e96f2584117b57cc85cc13d4d7606ca30 [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Building SINGA from source &mdash; incubator-singa 0.3.0 documentation</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="top" title="incubator-singa 0.3.0 documentation" href="../index.html"/>
<script src="../_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="../index.html" class="icon icon-home"> incubator-singa
<img src="../_static/singa.png" class="logo" />
</a>
<div class="version">
0.3.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../downloads.html">Download SINGA</a></li>
<li class="toctree-l1"><a class="reference internal" href="index.html">Documentation</a></li>
</ul>
<p class="caption"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../develop/schedule.html">Development Schedule</a></li>
<li class="toctree-l1"><a class="reference internal" href="../develop/how-contribute.html">How to Contribute to SINGA</a></li>
<li class="toctree-l1"><a class="reference internal" href="../develop/contribute-code.html">How to Contribute Code</a></li>
<li class="toctree-l1"><a class="reference internal" href="../develop/contribute-docs.html">How to Contribute Documentation</a></li>
</ul>
<p class="caption"><span class="caption-text">Community</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../community/source-repository.html">Source Repository</a></li>
<li class="toctree-l1"><a class="reference internal" href="../community/mail-lists.html">Project Mailing Lists</a></li>
<li class="toctree-l1"><a class="reference internal" href="../community/issue-tracking.html">Issue Tracking</a></li>
<li class="toctree-l1"><a class="reference internal" href="../community/team-list.html">The SINGA Team</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">incubator-singa</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> &raquo;</li>
<li>Building SINGA from source</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="building-singa-from-source">
<span id="building-singa-from-source"></span><h1>Building SINGA from source<a class="headerlink" href="#building-singa-from-source" title="Permalink to this headline"></a></h1>
<hr class="docutils" />
<div class="section" id="dependencies">
<span id="dependencies"></span><h2>Dependencies<a class="headerlink" href="#dependencies" title="Permalink to this headline"></a></h2>
<p>SINGA is developed and tested on Linux platforms.</p>
<p>The following dependent libraries are required:</p>
<ul class="simple">
<li>glog version 0.3.3</li>
<li>google-protobuf version 2.5 and 2.6</li>
<li>openblas version &gt;= 0.2.10</li>
</ul>
<p>Optional dependencies include:</p>
<ul class="simple">
<li>lmdb version 0.9.10</li>
<li>zeromq version &gt;= 3.2</li>
<li>czmq version &gt;= 3</li>
<li>zookeeper version 3.4.6</li>
</ul>
<p>You can install all dependencies (including optional dependent libraries) into $PREFIX folder by</p>
<div class="highlight-default"><div class="highlight"><pre><span></span># make sure you are in the thirdparty folder
cd thirdparty
./install.sh all $PREFIX
</pre></div>
</div>
<p>If $PREFIX is not a system path (e.g., /usr/local/), please export the following
variables to continue the building instructions,</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
export CPLUS_INCLUDE_PATH=$PREFIX/include:$CPLUS_INCLUDE_PATH
export LIBRARY_PATH=$PREFIX/lib:$LIBRARY_PATH
export PATH=$PREFIX/bin:$PATH
</pre></div>
</div>
<p>More details on using this script is given below.</p>
</div>
<div class="section" id="building-singa-from-source">
<span id="id1"></span><h2>Building SINGA from source<a class="headerlink" href="#building-singa-from-source" title="Permalink to this headline"></a></h2>
<p>SINGA is built using GNU autotools. GCC (version &gt;= 4.8) is required.
There are two ways to build SINGA,</p>
<ul>
<li><p class="first">If you want to use the latest code, please clone it from
<a class="reference external" href="https://github.com/apache/incubator-singa.git">Github</a> and execute
the following commands,</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ git clone git@github.com:apache/incubator-singa.git
$ cd incubator-singa
$ ./autogen.sh
$ ./configure
$ make
</pre></div>
</div>
</li>
<li><p class="first">If you download a release package, please follow the instructions below,</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ tar xvf singa-xxx
$ cd singa-xxx
$ ./configure
$ make
</pre></div>
</div>
<p>Some features of SINGA depend on external libraries. These features can be
compiled with <code class="docutils literal"><span class="pre">--enable-&lt;feature&gt;</span></code>.
For example, to build SINGA with lmdb support, you can run:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ ./configure --enable-lmdb
</pre></div>
</div>
<p>More options can be found by</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ ./configure --help
</pre></div>
</div>
</li>
</ul>
<p>After compiling SINGA successfully, the <em>libsinga.so</em> and the executable file
<em>singa</em> will be generated into <em>.libs/</em> folder.</p>
<p>If some dependent libraries are missing (or not detected), you can use the
following script to download and install them:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span># must goto thirdparty folder
$ cd thirdparty
$ ./install.sh LIB_NAME PREFIX
</pre></div>
</div>
<p>If you do not specify the installation path, the library will be installed in
the default folder specified by the software itself. For example, if you want
to install <code class="docutils literal"><span class="pre">zeromq</span></code> library in the default system folder, run it as</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ ./install.sh zeromq
</pre></div>
</div>
<p>Or, if you want to install it into another folder,</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ ./install.sh zeromq PREFIX
</pre></div>
</div>
<p>You can also install all dependencies in <em>/usr/local</em> directory:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ ./install.sh all /usr/local
</pre></div>
</div>
<p>Here is a table showing the first arguments:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">LIB_NAME</span> <span class="n">LIBRARIE</span>
<span class="n">czmq</span><span class="o">*</span> <span class="n">czmq</span> <span class="n">lib</span>
<span class="n">glog</span> <span class="n">glog</span> <span class="n">lib</span>
<span class="n">lmdb</span> <span class="n">lmdb</span> <span class="n">lib</span>
<span class="n">OpenBLAS</span> <span class="n">OpenBLAS</span> <span class="n">lib</span>
<span class="n">protobuf</span> <span class="n">Google</span> <span class="n">protobuf</span>
<span class="n">zeromq</span> <span class="n">zeromq</span> <span class="n">lib</span>
<span class="n">zookeeper</span> <span class="n">Apache</span> <span class="n">zookeeper</span>
</pre></div>
</div>
<p>*: Since <code class="docutils literal"><span class="pre">czmq</span></code> depends on <code class="docutils literal"><span class="pre">zeromq</span></code>, the script offers you one more argument to
indicate <code class="docutils literal"><span class="pre">zeromq</span></code> location.
The installation commands of <code class="docutils literal"><span class="pre">czmq</span></code> is:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$./install.sh czmq /usr/local -f=/usr/local/zeromq
</pre></div>
</div>
<p>After the execution, <code class="docutils literal"><span class="pre">czmq</span></code> will be installed in <em>/usr/local</em>. The last path
specifies the path to zeromq.</p>
<div class="section" id="faq">
<span id="faq"></span><h3>FAQ<a class="headerlink" href="#faq" title="Permalink to this headline"></a></h3>
<ul>
<li><p class="first">Q1:I get error <code class="docutils literal"><span class="pre">./configure</span> <span class="pre">--&gt;</span> <span class="pre">cannot</span> <span class="pre">find</span> <span class="pre">blas_segmm()</span> <span class="pre">function</span></code> even I
have installed OpenBLAS.</p>
<p>A1: This means the compiler cannot find the <code class="docutils literal"><span class="pre">OpenBLAS</span></code> library. If you installed
it to $PREFIX (e.g., /opt/OpenBLAS), then you need to export it as</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ export LIBRARY_PATH=$PREFIX/lib:$LIBRARY_PATH
# e.g.,
$ export LIBRARY_PATH=/opt/OpenBLAS/lib:$LIBRARY_PATH
</pre></div>
</div>
</li>
</ul>
<ul>
<li><p class="first">Q2: I get error <code class="docutils literal"><span class="pre">cblas.h</span> <span class="pre">no</span> <span class="pre">such</span> <span class="pre">file</span> <span class="pre">or</span> <span class="pre">directory</span> <span class="pre">exists</span></code>.</p>
<p>Q2: You need to include the folder of the cblas.h into CPLUS_INCLUDE_PATH,
e.g.,</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ export CPLUS_INCLUDE_PATH=$PREFIX/include:$CPLUS_INCLUDE_PATH
# e.g.,
$ export CPLUS_INCLUDE_PATH=/opt/OpenBLAS/include:$CPLUS_INCLUDE_PATH
# then reconfigure and make SINGA
$ ./configure
$ make
</pre></div>
</div>
</li>
</ul>
<ul>
<li><p class="first">Q3:While compiling SINGA, I get error <code class="docutils literal"><span class="pre">SSE2</span> <span class="pre">instruction</span> <span class="pre">set</span> <span class="pre">not</span> <span class="pre">enabled</span></code></p>
<p>A3:You can try following command:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ make CFLAGS=&#39;-msse2&#39; CXXFLAGS=&#39;-msse2&#39;
</pre></div>
</div>
</li>
</ul>
<ul>
<li><p class="first">Q4:I get <code class="docutils literal"><span class="pre">ImportError:</span> <span class="pre">cannot</span> <span class="pre">import</span> <span class="pre">name</span> <span class="pre">enum_type_wrapper</span></code> from
google.protobuf.internal when I try to import .py files.</p>
<p>A4:After install google protobuf by <code class="docutils literal"><span class="pre">make</span> <span class="pre">install</span></code>, we should install python
runtime libraries. Go to protobuf source directory, run:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ cd /PROTOBUF/SOURCE/FOLDER
$ cd python
$ python setup.py build
$ python setup.py install
</pre></div>
</div>
<p>You may need <code class="docutils literal"><span class="pre">sudo</span></code> when you try to install python runtime libraries in
the system folder.</p>
</li>
</ul>
<ul>
<li><p class="first">Q5: I get a linking error caused by gflags.</p>
<p>A5: SINGA does not depend on gflags. But you may have installed the glog with
gflags. In that case you can reinstall glog using <em>thirdparty/install.sh</em> into
a another folder and export the LDFLAGS and CPPFLAGS to include that folder.</p>
</li>
</ul>
<ul>
<li><p class="first">Q6: While compiling SINGA and installing <code class="docutils literal"><span class="pre">glog</span></code> on mac OS X, I get fatal error
<code class="docutils literal"><span class="pre">'ext/slist'</span> <span class="pre">file</span> <span class="pre">not</span> <span class="pre">found</span></code></p>
<p>A6:We haven&#8217;t tested SINGA thorough on Mac OS. This error may be fixed by :</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ make CFLAGS=&#39;-stdlib=libstdc++&#39; CXXFLAGS=&#39;stdlib=libstdc++&#39;
</pre></div>
</div>
</li>
<li><p class="first">Q7: When I start a training job, it reports error related with &#8220;ZOO_ERROR...zk retcode=-4...&#8221;.</p>
<p>A7: This is because the zookeeper is not started. Please start the zookeeper service</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ ./bin/zk-service start
</pre></div>
</div>
<p>If the error still exists, probably that you do not have java. You can simple
check it by</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ java --version
</pre></div>
</div>
</li>
<li><p class="first">Q8: When I build OpenBLAS from source, I am told that I need a fortran compiler.</p>
<p>A8: You can compile OpenBLAS by</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ make ONLY_CBLAS=1
</pre></div>
</div>
<p>or install it using</p>
<div class="highlight-default"><div class="highlight"><pre><span></span> $ sudo apt-get install openblas-dev
</pre></div>
</div>
<p>or</p>
<div class="highlight-default"><div class="highlight"><pre><span></span> $ sudo yum install openblas-devel
</pre></div>
</div>
<p>It is worth noting that you need root access to run the last two commands.
Remember to set the environment variables to include the header and library
paths of OpenBLAS after installation (please refer to the Dependencies section).</p>
</li>
<li><p class="first">Q9: When I build protocol buffer, it reports that GLIBC++_3.4.20 not found in /usr/lib64/libstdc++.so.6.</p>
<p>A9: This means the linker found libstdc++.so.6 but that library
belongs to an older version of GCC than was used to compile and link the
program. The program depends on code defined in
the newer libstdc++ that belongs to the newer version of GCC, so the linker
must be told how to find the newer libstdc++ shared library.
The simplest way to fix this is to find the correct libstdc++ and export it to
LD_LIBRARY_PATH. For example, if GLIBC++_3.4.20 is listed in the output of the
following command,</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ strings /usr/local/lib64/libstdc++.so.6|grep GLIBC++
</pre></div>
</div>
<p>then you just set your environment variable as</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$ export LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH
</pre></div>
</div>
</li>
<li><p class="first">Q10: When I build glog, it reports that &#8220;src/logging_unittest.cc:83:20: error: ‘gflags’ is not a namespace-name&#8221;</p>
<p>A10: It maybe that you have installed gflags with a different namespace such as &#8220;google&#8221;. so glog can&#8217;t find &#8216;gflags&#8217; namespace.</p>
<p>Because it doesn&#8217;t require gflags to build glog. So you can change the configure.ac file to ignore gflags.</p>
<ol class="simple">
<li>cd to glog src directory</li>
<li>change line 125 of configure.ac to &#8220;AC_CHECK_LIB(gflags, main, ac_cv_have_libgflags=0, ac_cv_have_libgflags=0)&#8221;</li>
<li>autoreconf</li>
</ol>
<p>After this, you can build glog again.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2016 The Apache Software Foundation. All rights reserved. Apache Singa, Apache, the Apache feather logo, and the Apache Singa project logos are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners..
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'0.3.0',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</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="../_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
<div class="rst-versions shift-up" data-toggle="rst-versions" role="note" aria-label="versions">
<img src="../_static/apache.jpg">
<span class="rst-current-version" data-toggle="rst-current-version">
<span class="fa fa-book"> incubator-singa </span>
v: 0.3.0
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
<dl>
<dt>Languages</dt>
<dd><a href="../../en/index.html">English</a></dd>
<dd><a href="../../zh/index.html">中文</a></dd>
<dd><a href="../../jp/index.html">日本語</a></dd>
<dd><a href="../../kr/index.html">한국어</a></dd>
</dl>
</div>
</div>
<a href="https://github.com/apache/incubator-singa">
<img style="position: absolute; top: 0; right: 0; border: 0; z-index: 10000;"
src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"
alt="Fork me on GitHub">
</a>
</body>
</html>