Fork me on GitHub

Building SINGA from source


SINGA is developed and tested on Linux platforms.

The following dependent libraries are required:

  • glog version 0.3.3

  • google-protobuf version 2.5 and 2.6

  • openblas version >= 0.2.10

Optional dependencies include:

  • lmdb version 0.9.10

  • zeromq version >= 3.2

  • czmq version >= 3

  • zookeeper version 3.4.6

You can install all dependencies (including optional dependent libraries) into $PREFIX folder by

# make sure you are in the thirdparty folder
cd thirdparty
./ all $PREFIX

If $PREFIX is not a system path (e.g., /usr/local/), please export the following variables to continue the building instructions,

export PATH=$PREFIX/bin:$PATH

More details on using this script is given below.

Building SINGA from source

SINGA is built using GNU autotools. GCC (version >= 4.8) is required. There are two ways to build SINGA,

  • If you want to use the latest code, please clone it from Github and execute the following commands,

    $ git clone
    $ cd incubator-singa
    $ ./
    $ ./configure
    $ make
  • If you download a release package, please follow the instructions below,

    $ tar xvf singa-xxx
    $ cd singa-xxx
    $ ./configure
    $ make

    Some features of SINGA depend on external libraries. These features can be compiled with --enable-<feature>. For example, to build SINGA with lmdb support, you can run:

    $ ./configure --enable-lmdb

    More options can be found by

    $ ./configure --help

After compiling SINGA successfully, the and the executable file singa will be generated into .libs/ folder.

If some dependent libraries are missing (or not detected), you can use the following script to download and install them:

# must goto thirdparty folder
$ cd thirdparty

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 zeromq library in the default system folder, run it as

$ ./ zeromq

Or, if you want to install it into another folder,

$ ./ zeromq PREFIX

You can also install all dependencies in /usr/local directory:

$ ./ all /usr/local

Here is a table showing the first arguments:

czmq*                 czmq lib
glog                  glog lib
lmdb                  lmdb lib
OpenBLAS              OpenBLAS lib
protobuf              Google protobuf
zeromq                zeromq lib
zookeeper             Apache zookeeper

*: Since czmq depends on zeromq, the script offers you one more argument to indicate zeromq location. The installation commands of czmq is:

$./ czmq  /usr/local -f=/usr/local/zeromq

After the execution, czmq will be installed in /usr/local. The last path specifies the path to zeromq.


  • Q1:I get error ./configure --> cannot find blas_segmm() function even I have installed OpenBLAS.

A1: This means the compiler cannot find the OpenBLAS library. If you installed it to $PREFIX (e.g., /opt/OpenBLAS), then you need to export it as

  # e.g.,
  $ export LIBRARY_PATH=/opt/OpenBLAS/lib:$LIBRARY_PATH
  • Q2: I get error cblas.h no such file or directory exists.

Q2: You need to include the folder of the cblas.h into CPLUS_INCLUDE_PATH, e.g.,

  # e.g.,
  # then reconfigure and make SINGA
  $ ./configure
  $ make
  • Q3:While compiling SINGA, I get error SSE2 instruction set not enabled

A3:You can try following command:

  $ make CFLAGS='-msse2' CXXFLAGS='-msse2'
  • Q4:I get ImportError: cannot import name enum_type_wrapper from google.protobuf.internal when I try to import .py files.

A4:After install google protobuf by make install, we should install python runtime libraries. Go to protobuf source directory, run:

  $ cd python
  $ python build
  $ python install

You may need sudo when you try to install python runtime libraries in the system folder.

  • Q5: I get a linking error caused by gflags.

A5: SINGA does not depend on gflags. But you may have installed the glog with gflags. In that case you can reinstall glog using thirdparty/ into a another folder and export the LDFLAGS and CPPFLAGS to include that folder.

  • Q6: While compiling SINGA and installing glog on mac OS X, I get fatal error 'ext/slist' file not found

A6:We haven’t tested SINGA thorough on Mac OS. This error may be fixed by :

  $ make CFLAGS='-stdlib=libstdc++' CXXFLAGS='stdlib=libstdc++'
  • Q7: When I start a training job, it reports error related with “ZOO_ERROR…zk retcode=-4…”.

A7: This is because the zookeeper is not started. Please start the zookeeper service

  $ ./bin/zk-service start

If the error still exists, probably that you do not have java. You can simple check it by

  $ java --version
  • Q8: When I build OpenBLAS from source, I am told that I need a fortran compiler.

A8: You can compile OpenBLAS by

  $ make ONLY_CBLAS=1

or install it using

    $ sudo apt-get install openblas-dev


    $ sudo yum install openblas-devel

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).

  • Q9: When I build protocol buffer, it reports that GLIBC++_3.4.20 not found in /usr/lib64/

A9: This means the linker found 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,

  $ strings /usr/local/lib64/|grep GLIBC++

then you just set your environment variable as

  $ export LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH
  • Q10: When I build glog, it reports that “src/ error: ‘gflags’ is not a namespace-name”

A10: It maybe that you have installed gflags with a different namespace such as “google”. so glog can’t find ‘gflags’ namespace.

Because it doesn’t require gflags to build glog. So you can change the file to ignore gflags.

  1. cd to glog src directory
  2. change line 125 of to “AC_CHECK_LIB(gflags, main, ac_cv_have_libgflags=0, ac_cv_have_libgflags=0)”
  3. autoreconf

After this, you can build glog again.