The process of building SINGA from source on Microsoft Windows has four parts: install dependencies, build SINGA source, (optionally) install the python module and (optionally) run the unit tests.
You may create a folder for building the dependencies.
The dependencies are:
Compiler and IDE
CMake
SWIG
Protocol Buffers
Openblas
cmake -G "Visual Studio 15 2017 Win64"
Google glog
Download SINGA source code
Compile the protobuf files:
mkdir python_out protoc.exe *.proto --python_out python_out
Generate swig interfaces for C++ and Python: Goto src/api
swig -python -c++ singa.i
generate Visual Studio solution for SINGA: Goto SINGA source code root folder
mkdir build
cd build
Call cmake and add the paths in your system similar to the following example:
cmake -G "Visual Studio 15 2017 Win64" ^ -DGLOG_INCLUDE_DIR="D:/WinSinga/dependencies/glog-0.3.5/src/windows" ^ -DGLOG_LIBRARIES="D:/WinSinga/dependencies/glog-0.3.5/x64/Release" ^ -DCBLAS_INCLUDE_DIR="D:/WinSinga/dependencies/openblas-0.2.20/lapack-netlib/CBLAS/include" ^ -DCBLAS_LIBRARIES="D:/WinSinga/dependencies/openblas-0.2.20/lib/RELEASE" ^ -DProtobuf_INCLUDE_DIR="D:/WinSinga/dependencies/protobuf-2.6.1/src" ^ -DProtobuf_LIBRARIES="D:/WinSinga/dependencies/protobuf-2.6.1/vsprojects/x64/Release" ^ -DProtobuf_PROTOC_EXECUTABLE="D:/WinSinga/dependencies/protoc-2.6.1-win32/protoc.exe" ^ ..
Open the generated solution in Visual Studio
Change the build settings to Release and x64
Add the singa_wrap.cxx file from src/api to the singa_objects project
In the singa_objects project, open Additional Include Directories.
Add Python include path
Add numpy include path
Add protobuf include path
In the preprocessor definitions of the singa_objects project, add USE_GLOG
Build singa_objects project
In singa project:
build singa project
Change _singa_wrap.so
to _singa_wrap.pyd
in build/python/setup.py
Copy the files in src/proto/python_out
to build/python/singa/proto
Optionally create and activate a virtual environment:
mkdir SingaEnv virtualenv SingaEnv SingaEnv\Scripts\activate
goto build/python folder and run:
python setup.py install
Make _singa_wrap.pyd, libglog.dll and libopenblas.dll available by adding them to the path or by copying them to singa package folder in the python site-packages
Verify that SINGA is installed by running:
python -c "from singa import tensor"
A video tutorial for the build process can be found here:
In the test folder, generate the Visual Studio solution:
cmake -G "Visual Studio 15 2017 Win64"
Open the generated solution in Visual Studio.
Change the build settings to Release and x64.
Build glog project.
In test_singa project:
Build test_singa project.
Make libglog.dll and libopenblas.dll available by adding them to the path or by copying them to test/release folder
The unit tests can be executed
test_singa.exe
A video tutorial for running the unit tests can be found here:
In this section, we will extend the previous steps to enable GPU.
In addition to the dependencies in section 1 above, we will need the following:
CUDA
Download a suitable version such as 9.1 from https://developer.nvidia.com/cuda-downloads . Make sure to install the Visual Studio integration module.
cuDNN
Download a suitable version such as 7.1 from https://developer.nvidia.com/cudnn
cnmem:
cmake -G "Visual Studio 15 2017 Win64"
cmake -G "Visual Studio 15 2017 Win64" ^ -DGLOG_INCLUDE_DIR="D:/WinSinga/dependencies/glog-0.3.5/src/windows" ^ -DGLOG_LIBRARIES="D:/WinSinga/dependencies/glog-0.3.5/x64/Release" ^ -DCBLAS_INCLUDE_DIR="D:/WinSinga/dependencies/openblas-0.2.20/lapack-netlib/CBLAS/include" ^ -DCBLAS_LIBRARIES="D:/WinSinga/dependencies/openblas-0.2.20/lib/RELEASE" ^ -DProtobuf_INCLUDE_DIR="D:/WinSinga/dependencies/protobuf-2.6.1/src" ^ -DProtobuf_LIBRARIES="D:\WinSinga/dependencies/protobuf-2.6.1/vsprojects/x64/Release" ^ -DProtobuf_PROTOC_EXECUTABLE="D:/WinSinga/dependencies/protoc-2.6.1-win32/protoc.exe" ^ -DCUDNN_INCLUDE_DIR=D:\WinSinga\dependencies\cudnn-9.1-windows10-x64-v7.1\cuda\include ^ -DCUDNN_LIBRARIES=D:\WinSinga\dependencies\cudnn-9.1-windows10-x64-v7.1\cuda\lib\x64 ^ -DSWIG_DIR=D:\WinSinga\dependencies\swigwin-3.0.12 ^ -DSWIG_EXECUTABLE=D:\WinSinga\dependencies\swigwin-3.0.12\swig.exe ^ -DUSE_CUDA=YES ^ -DCUDNN_VERSION=7 ^ ..
Generate swig interfaces for C++ and Python: Goto src/api
swig -python -c++ singa.i
Open the generated solution in Visual Studio
Change the build settings to Release and x64
Create a new Visual Studio project of type “CUDA 9.1 Runtime”. Give it a name such as singa-kernel.
The project comes with an initial file called kernel.cu. Remove this file from the project.
Add this file: src/core/tensor/math_kernel.cu
In the project settings:
Build singa-kernel project
In singa project:
build singa project
Change _singa_wrap.so to _singa_wrap.pyd in build/python/setup.py
Copy the files in src/proto/python_out to build/python/singa/proto
Optionally create and activate a virtual environment:
mkdir SingaEnv virtualenv SingaEnv SingaEnv\Scripts\activate
goto build/python folder and run:
python setup.py install
Make _singa_wrap.pyd, libglog.dll, libopenblas.dll, cnmem.dll, CUDA Runtime (e.g. cudart64_91.dll) and cuDNN (e.g. cudnn64_7.dll) available by adding them to the path or by copying them to singa package folder in the python site-packages
Verify that SINGA is installed by running:
python -c "from singa import device; dev = device.create_cuda_gpu()"
A video tutorial for this part can be found here:
In the test folder, generate the Visual Studio solution:
cmake -G "Visual Studio 15 2017 Win64"
Open the generated solution in Visual Studio, or add the project to the singa solution that was created in step 5.2
Change the build settings to Release and x64.
Build glog project.
In test_singa project:
Build test_singa project.
Make libglog.dll, libopenblas.dll, cnmem.dll, cudart64_91.dll and cudnn64_7.dll available by adding them to the path or by copying them to test/release folder
The unit tests can be executed
From the command line:
test_singa.exe
From Visual Studio:
A video tutorial for running the unit tests can be found here: