Getting Started with ThunderSVM

Here we provide a quick start tutorial for users to install ThunderSVM.

Prerequisites

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

Installation

If you don’t have GPUs, please go to Working without GPUs in later section of this page.

Installation for Linux

  • Clone ThunderSVM repository
git clone https://github.com/zeyiwen/thundersvm.git
  • Build ThunderSVM
mkdir build
cd build
cmake ..
make -j

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

Installation for MacOS

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

You need to Install CMake and gcc for MacOS. If you don’t have Homebrew, here is its website.

brew install gcc
brew install cmake
  • Build ThunderSVM. You can specify gcc as the compiler of cmake. ([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

Installation for Windows

  • Clone ThunderSVM repository
git clone https://github.com/zeyiwen/thundersvm.git
  • Create a Visual Studio project
mkdir build
cd build
cmake .. -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -G "Visual Studio 14 2015 Win64"

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.

Working without GPUs

If you don’t have GPUs, ThunderSVM can run purely on CPUs. The number of CPU cores to use can be specified by the -o option (e.g., -o 10), and refer to Parameters for more information.

  • Clone ThunderSVM repository
git clone https://github.com/zeyiwen/thundersvm.git
  • Get Eigen Library. ThunderSVM uses Eigen for matrix calculation. To use Eigen, just initialize the submodule.
# in thundersvm root directory
git submodule init eigen && git submodule update
  • Build without GPUs for Linux
# in thundersvm root directory
mkdir build && cd build && cmake -DUSE_CUDA=OFF -DUSE_EIGEN=ON .. && make -j

If make -j doesn’t work, please simply use make. Now ThunderSVM will work solely on CPUs and does not rely on CUDA.

  • Build without GPUs for MacOS
# in thundersvm root directory
mkdir build && cd build && cmake -DCMAKE_CXX_COMPILER=[path_to_g++] -DCMAKE_C_COMPILER=[path_to_gcc] -DUSE_CUDA=OFF -DUSE_EIGEN=ON .. && make -j
  • Build without GPUs for Windows
mkdir build
cd build
cmake .. -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -DUSE_CUDA=OFF -DUSE_EIGEN=ON -G "Visual Studio 14 2015 Win64"

Then, you can open the generated the Visual Studio project file to build ThunderSVM.

Training SVMs

We show some concrete examples of using ThunderSVM. ThunderSVM uses the same command line options as LibSVM, so existing users of LibSVM can use ThunderSVM easily. For new users of SVMs, the Parameters page provides explanation for the usage of each option.

Training SVMs for Classification

In the following, we provide an example of using ThunderSVM for the MNIST dataset.

  • Download the MNIST data set. The data set is available in this link.
  • Decompress the data set. For Windows machines, you can decompress the data set using tools such as 7-Zip. For Unix based OSes, you can use
bunzip2 mnist.scale.bz2
  • Install ThunderSVM. Instructions available in the previous sections of this page.
  • Run ThunderSVM
./thundersvm-train -s 0 -t 2 -g 0.125 -c 10 mnist.scale svm.model

The meaning of each option can be found in the Parameters page. The training takes a while to complete. Once completed, you can see the classifier accuracy is 94.32%.

Training SVMs for Regression

The usage of other SVM algorithms (such as SVM regression) is similar to the above example. The key difference is the selection of the options. Let’s take the Abalone data set as an example.

  • Download the Abalone data set. The data set is available in this link.
  • Install ThunderSVM. Instructions available in the previous sections of this page.
  • Run ThunderSVM
./thundersvm-train -s 3 -t 2 -g 3.8 -c 1000 abalone_scale svm.model

The meaning of each option can be found in the Parameters page.

Interfaces

ThunderSVM provides Python, R and Matlab interfaces. You can find the instructions in the corresponding subdirectories on GitHub.