ThunderSVM How To

This page is for key instructions of intalling, using and contributing to ThunderSVM. ThunderSVM has been used by many users, and everyone can contribute to ThunderSVM to make it better.

Install ThunderSVM

To use ThunderSVM, we need to install the following software:

  • cmake 2.8 or above
  • gcc 4.8 or above for Linux and MacOS; Visual C++ for Windows

If you want to use GPUs, you also need to install CUDA.

After installing the above software, you can start compiling ThunderSVM.

  • Clone ThunderSVM repository
git clone https://github.com/zeyiwen/thundersvm.git

If you don’t have a GPU or want to run ThunderSVM purely on CPUs, you need to add a submodule to ThunderSVM by the following command. Please refer to Working without GPUs for more information.

# in thundersvm root directory
git submodule init eigen && git submodule update
  • Build the executable for Linux, use the following commands.
cd thundersvm
mkdir build
cd build
cmake ..
make -j

If make -j doesn’t work, please simply use make instead.

  • Build for MacOS, use the following commands ([path_to_g++] and [path_to_gcc] typically look like /usr/local/bin/g++-7 and /usr/local/bin/gcc-7, respectively.).
# in thundersvm root directory
mkdir build
cd build
cmake -DCMAKE_CXX_COMPILER=[path_to_g++] -DCMAKE_C_COMPILER=[path_to_gcc] -DUSE_CUDA=ON -DUSE_EIGEN=OFF ..
make -j
  • Build the executable for Windows, use the following example commands. You need to change the Visual Studio version if you are using a different version of Visual Studio.
mkdir build
cd build
cmake ..  -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -G "Visual Studio 14 2015 Win64"

The above commands generate some Visual Studio project files, open the Visual Studio project in the build directory to start building ThunderSVM on Windows. Please note that CMake should be 3.4 or above for Windows.

You can now use ThunderSVM, and the options of executing ThunderSVM are available here. Please refer to Getting Started for some examples of training SVMs using ThunderSVM.

Improve documentations

Most of the documents can be viewed on GitHub, although the documents look much better in Read the Doc. The HTML files of our documents are generated by Sphinx, and the source files of the documents are written using Markdown. In the following, we describe how to setup the Sphinx environment for ThunderSVM.

  • Install sphinx
pip install sphinx
  • Install Makedown Parser
pip install recommonmark

Note that recommonmark has a bug when working with Sphinx in some platforms, so you may need to hack into transform.py to fix the problem by yourself. You can find the instruction of hacking in this link.

  • Install Sphinx theme
pip install sphinx_rtd_theme
  • Generate HTML

    Go to the “docs” directory of ThunderSVM and run:

make html

At this point, make sure you have generated the documents of ThunderSVM. You can build the documents in your machine to see the outcome.

Contribute to ThunderSVM

You need to fetch the latest version of ThunderSVM before submitting a pull request.

git remote add upstream https://github.com/zeyiwen/thundersvm.git
git fetch upstream
git rebase upstream/master

Test ThunderSVM

We recommend our contributors using Linux as the development platform where ThunderSVM is relatively well tested.

Please note that cmake .. [-D<options>=<args>] produces a CMakeCache.txt file. You need to remove it or the whole build directory, before you can run a new cmake command with different configurations. Also please note that the test build will not generate binaries like thundersvm-train.

Build test on Linux

  • Clone ThunderSVM repository
git clone https://github.com/zeyiwen/thundersvm.git
git submodule update --init src/test/googletest
  • Build the binary for testing
mkdir build
cd build
cmake .. -DBUILD_TESTS=ON
make -j runtest

If make -j runtest doesn’t work, please use make runtest instead. Make sure all the test cases pass. You can also add more test cases in the test module of ThunderSVM.

Build test on MacOS

  • Clone ThunderSVM repository
git clone https://github.com/zeyiwen/thundersvm.git
git submodule init eigen && git submodule update
git submodule update --init src/test/googletest
  • Build the binary for testing
mkdir build
cd build
cmake .. -DCMAKE_CXX_COMPILER=[path_to_g++]/usr/local/bin/g++-7 -DCMAKE_C_COMPILER=[path_to_gcc] -DUSE_CUDA=OFF -DUSE_EIGEN=ON -DBUILD_TESTS=ON
make -j runtest

Where [path_to_g++] and [path_to_gcc] typically look like /usr/local/bin/g++-7 and /usr/local/bin/gcc-7, respectively.

Build test on Windows

  • Clone ThunderSVM repository
git clone https://github.com/zeyiwen/thundersvm.git
git submodule update --init src/test/googletest
  • Build the binary for testing
mkdir build
cd build
cmake .. -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -DBUILD_TESTS=ON -G "Visual Studio 14 2015 Win64"
cmake --build . --target runtest

You need to change the Visual Studio version if you are using a different version of Visual Studio. Visual Studio can be downloaded from this link. The above commands generate some Visual Studio project files, open the Visual Studio project to build ThunderSVM. Please note that CMake should be 3.4 or above for Windows.