- Notifications
You must be signed in to change notification settings - Fork25
Spiking Neural Networks in C++ with strong GPU acceleration through CUDA
License
tudelft/cuSNN
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
cuSNN is a C++ library that enables GPU-accelerated simulations of large-scale Spiking Neural Networks (SNNs).
This project was created for the work"Unsupervised Learning of a Hierarchical Spiking Neural Network for Optical FlowEstimation: From Events to Global Motion Perception" (Paredes-Vallés, F., Scheper, K.Y., and de Croon, G.C.H.E., 2018).
If you use this library in an academic publication, please cite our work:
@article{paredes2020unsupervised, title={Unsupervised Learning of a Hierarchical Spiking Neural Network for Optical Flow Estimation: From Events to Global Motion Perception}, author={Paredes-Valles, Federico and Scheper, Kirk Yannick Willehm and De Croon, Guido Cornelis Henricus Eugene}, journal={IEEE Transactions on Pattern Analysis and Machine Intelligence}, year={2020}, volume={42}, number={8}, pages={2051-2064}, publisher={IEEE}}
cuSNN is a library that consists of the following files:
File | Description |
---|---|
cusnn.cu/.cuh | CUDA GPU engine |
cusnn_kernels.cu/.cuh | CUDA device functions for GPU engine |
In cuSNN, a SNN is defined using the following host/device classes:
Classes | Content |
---|---|
Network | Layer objects and architecture parameters. |
Network ->Layer | Kernel object and layer parameters. |
Network -> Layer ->Kernel | Neural and synaptic parameters. |
The cuSNN library has been tested on Linux systems only.
- Conv2d: 2D convolution over an input neural map composed of several input channels.
- Conv2dSep: 2D separable convolution over an input neural map composed of several input channels.
- Pooling: 2D pooling over an input neural map composed of several input channels.
- Merge: 1x1 convolution with unitary weights over an input neural map composed of several input channels.
- Dense: Full connectivity to an input neural map composed of several input channels.
At the moment, only the models proposed in our work are implemented. These are:
- Leaky Integrate-and-Fire (LIF) neuron model
- Trace-based adaptive LIF neuron model
- Static synapse model
At the moment, only the following learning rules are implemented:
- Unsupervised Learning:
Requirements:
- CMake3.8 (or higher)
- NVIDIA CUDA Toolkit8.0 (or higher)
Get the cuSNN source:
git clone https://github.com/fedepare/cuSNN.gitcd cuSNN
Install cuSNN:
Run the following Python script to install the cuSNN library:
python setup.py <install_dir> # Python 2.*python3 setup.py <install_dir> # Python 3.*
By default, cuSNN installation directory is/usr/local
. Hence, administrative privileges may be required. A differentinstallation directory can be specified using the<install_dir>
argument, as indicated above.
To uninstall all files, run:
xargs rm < build/install_manifest.txt
Again, administrative privileges may be required depending on your instllation directory.
Several samples are available to demonstrate the main features provided by the cuSNN library. These are stored in thesubmodulecuSNN-samples. To incorporate them to your current directory,run:
git submodule update --init --recursive
P.S.: This process can be a bit slow since a small dataset is included.
In Linux, the samples are built using makefiles. For this, go to the sample directory you wish and run:
make cleanmake
In the makefile of each sample, there are compilation flags to adapt the simulation to your needs. Depending on theirvalue, some of the following libraries may be required:
- PLOTTER:OpenGL andFreeGLUT for visualization
- SNAPSHOT:cnpy library for converting C++ arrays toNumpy
In case your installation directory differs from/usr/local
,-lcuSNN
needs to be removed fromthe definition of theLIBSUSR*
compilation flags, andLIBSCUSTOM
needs to be defined as follows:
LIBSCUSTOM = -I<install_dir>/include -L<install_dir>/lib -lcuSNN
Further, if your installation directory differs from/usr/local
, you may need to include the installationdirectory to yourLD_LIBRARY_PATH
environment variable so the executable can find the library at runtime. You can dothis by adding the following line to your~/.bashrc
file:
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:<install_dir>/lib"export LD_LIBRARY_PATH
or by running the following command in every new terminal window in which a cuSNN sample wants to be run:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<install_dir>/lib
Once the sample of your choice is built as explained above, simply run the executable as follows:
./build/main
cuSNN is currently maintained byFede Paredes-Vallés,Kirk Scheper, andGuido de Croon.