From Conda

Conda is a package manager for Python, CPP and other packages.

Currently, SINGA has conda packages (Python 2.7 and Python 3.6) for Linux and MacOSX.Miniconda3 is recommended to use with SINGA. After installing miniconda, execute the one of the following commands to install SINGA.

  1. CPU only

     conda install -c nusdbsystem singa-cpu
    
  2. GPU with CUDA and cuDNN

     conda install -c nusdbsystem singa-gpu
    

    CUDA driver (for CUDA >=9.0) must be installed before executing the above command. Singa packages for other CUDA versions are also available. The following instruction lists all the available Singa packages.

       conda search -c nusdbsystem singa
    

If there is no error message from

python -c "from singa import tensor"

then SINGA is installed successfully.

From source

The source files could be downloaded either as a tar.gz file, or as a git repo

$ git clone https://github.com/apache/incubator-singa.git
$ cd incubator-singa/

Use Conda to build SINGA

Conda-build is a building tool that installs the dependent libraries from anaconda cloud and executes the building scripts. The generated package can be uploaded to anaconda cloud for others to download and install.

To install conda-build (after installing miniconda)

conda install conda-build

To build the CPU version of SINGA

conda build tool/conda/singa/ --python 3.6

The above commands have been tested on Ubuntu 16.04 and Mac OSX. Refer to the Travis-CI page for more information.

To build the GPU version of SINGA

export CUDA=x.y (e.g. 9.0)
conda build tool/conda/singa/ --python 3.6

The commands for building on GPU platforms have been tested on Ubuntu 16.04 (cuDNN>=7 and CUDA>=9). Nvidia’s Docker image provides the building environment with cuDNN and CUDA.

The location of the generated package file is shown on the screen. Refer to conda install for the instructions of installing the package from the local file.

Use native tools to build SINGA on Ubuntu

The following libraries are required to compile and run SINGA. Refer to SINGA Dockerfiles for the instructions of installing them on Ubuntu 16.04.

  1. create a build folder inside incubator-singa and go into that folder

  2. run cmake [options] .. by default all options are OFF except USE_PYTHON

  3. compile the code, make

  4. goto python folder

  5. run pip install . or pip install -e . The second command creates symlinks instead of copying files into python site-package folder.

Execute step 4 and 5 are to install PySINGA when USE_PYTHON=ON.

After compiling SINGA with ENABLE_TEST=ON, you can run the unit tests by

$ ./bin/test_singa

You can see all the testing cases with testing results. If SINGA passes all tests, then you have successfully installed SINGA.

Compile SINGA on Windows

Instructions for building on Windows with Python support can be found here.

More details about the compilation options


USE_MODULES

If protobuf and openblas are not installed, you can compile SINGA together with them

$ In SINGA ROOT folder
$ mkdir build
$ cd build
$ cmake -DUSE_MODULES=ON ..
$ make

cmake would download OpenBlas and Protobuf (2.6.1) and compile them together with SINGA.

You can use ccmake .. to configure the compilation options. If some dependent libraries are not in the system default paths, you need to export the following environment variables

export CMAKE_INCLUDE_PATH=<path to the header file folder>
export CMAKE_LIBRARY_PATH=<path to the lib file folder>

USE_PYTHON

Similar to compile CPP code, PySINGA is compiled by

$ cmake -DUSE_PYTHON=ON ..
$ make
$ cd python
$ pip install .

USE_CUDA

Users are encouraged to install the CUDA and cuDNN for running SINGA on GPUs to get better performance.

SINGA has been tested over CUDA 9, and cuDNN 7. If cuDNN is installed into non-system folder, e.g. /home/bob/local/cudnn/, the following commands should be executed for cmake and the runtime to find it

$ export CMAKE_INCLUDE_PATH=/home/bob/local/cudnn/include:$CMAKE_INCLUDE_PATH
$ export CMAKE_LIBRARY_PATH=/home/bob/local/cudnn/lib64:$CMAKE_LIBRARY_PATH
$ export LD_LIBRARY_PATH=/home/bob/local/cudnn/lib64:$LD_LIBRARY_PATH

The cmake options for CUDA and cuDNN should be switched on

# Dependent libs are install already
$ cmake -DUSE_CUDA=ON ..
$ make

USE_OPENCL

SINGA uses opencl-headers and viennacl (version 1.7.1 or newer) for OpenCL support, which can be installed using via

# On Ubuntu 16.04
$ sudo apt-get install opencl-headers, libviennacl-dev
# On Fedora
$ sudo yum install opencl-headers, viennacl

Additionally, you will need the OpenCL Installable Client Driver (ICD) for the platforms that you want to run OpenCL on.

Note that running OpenCL on CPUs is not currently recommended because it is slow. Memory transfer is on the order of whole seconds (1000’s of ms on CPUs as compared to 1’s of ms on GPUs).

More information on setting up a working OpenCL environment may be found here.

If the package version of ViennaCL is not at least 1.7.1, you will need to build it from source:

Clone the repository from here, checkout the release-1.7.1 tag and build it. Remember to add its directory to PATH and the built libraries to LD_LIBRARY_PATH.

To build SINGA with OpenCL support (tested on SINGA 1.1):

$ cmake -DUSE_OPENCL=ON ..
$ make

USE_MKLDNN

User can enable MKL-DNN to enhance the performance of CPU computation.

Installation guide of MKL-DNN could be found here.

SINGA has been tested over MKL-DNN v0.17.2.

To build SINGA with MKL-DNN support:

# Dependent libs are installed already
$ cmake -DUSE_MKLDNN=ON ..
$ make

PACKAGE

This setting is used to build the Debian package. Set PACKAGE=ON and build the package with make command like this:

$ cmake -DPACKAGE=ON
$ make package

FAQ