Introduction

Abstruct

BinaryBrain is a deep learning platform created mainly for the purpose of experimenting with the LUT (Look-Up Table) -Network under study by this site.

It is created for the purpose of LUT-Network evaluation, but it can also be used for other purposes.

It has the following features

  • The main target is FPGA(field-programmable gate array).
  • Autoencode and regression analysis are possible with modulation technology despite being a binary net.
  • With the original Sparse-LUT model, the LUT performance can be maximized and learned.
  • Aiming to create an environment where high-performance learning is possible with a network of quantization and sparse matrix
  • Developed in C++
  • Accelerated with GPU (CUDA)
  • Easy to create high speed custom layers
  • Available from Python

Quick Start (C++)

First, introduce how to move the attached MNIST sample.

It assumes a CPU that can use AXV2 or later instructions and a Windows7 or later or Linux environment.Although it supports CUDA, it must be built in an environment where nvcc is available.

please install CUDA.https://developer.nvidia.com/cuda-downloads

When don’t use GPU, add option “make WITH_CUDA=No”

Windows

  1. install VisualStudio 2017 + CUDA 10.1
  2. git clone –recursive -b ver3_release https://github.com/ryuz/BinaryBrain.git
  3. download MNIST from http://yann.lecun.com/exdb/mnist/
  4. decompress MNIST for “samplesmnist”
  5. open VC++ solution “samplesmnistsample_mnist.sln”
  6. build “x64 Release”
  7. run

Linux(Ubuntu 18.04.1)

1. install tools

% sudo apt update
% sudo apt upgrade
% sudo apt install git
% sudo apt install make
% sudo apt install g++
% # sudo apt install nvidia-cuda-toolkit
% wget http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_418.87.00_linux.run
% sudo sh cuda_10.1.243_418.87.00_linux.run

2. build and run

% git clone --recursive -b ver3_release  https://github.com/ryuz/BinaryBrain.git
% cd BinaryBrain/samples/mnist
% make
% make dl_data
% ./sample-mnist All

Google Colaboratory

Google Colaboratory (runtime type is ‘GPU’)

!git clone --recursive -b ver3_release  https://github.com/ryuz/BinaryBrain.git
%cd BinaryBrain/samples/mnist
!make all
!make run

Quick Start (Python)

BinaryBrain also enables calls from Python using pybind11. python3 is assumed.

install with pip

It can be installed with the following command.

% pip3 install binarybrain==3.13.*

Depending on the environment such as Windows, pip3 does not exist. If only pip is used, replace pip3 with pip.Since the source file is built at the time of installation, it is necessary to prepare the environment such as compiler and CUDA beforehand.(Windows version may be provided with binary wheel)

Refer to the following for sample programs for Python.

https://github.com/ryuz/BinaryBrain/tree/master/python/samples

install with setup.py

preparation

Please install the following packages first

% pip3 install setuptools
% pip3 install pybind11
% pip3 install numpy
% pip3 install tqdm

In Windows environment, in addition to nvcc, VisualStudio 64bit The version must be available from the command line. For example, run it as follows. The x64 specification is important.

> "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64

install

It can be installed with the following command.

% # install
% cd python
% python3 setup.py install

About github

Currently version3 is managed by the following branch

ver3_develop
Development branch. It may be impossible to build. See here if you want to access the latest code.
ver3_release
A branch for creating a release.
master
Reflect what was confirmed in the release branch.

The tag is typed regularly in the format ver3_build0001 for the convenience of development, and the version number tag is typed at the release timing. (In the past, I used to type in ver3_release1 for each release).

The specifications are not yet stable at the beginning of development, so use tags when you need to ensure reproducibility.

Basic usage

Basically, you can design the network in C ++ or Python, and run learning and output verilog RTL for FPGA.

Of course, BinaryBrain itself is mainly up to learning network parameters by learning, so users can freely develop routines that output C language using the results.

The CPU version for C ++ is a header-only library, so you can use it just by including the header file under include. When using GPU, it is necessary to define the BB_WITH_CUDA macro when reading the header, and link after building the library under cuda.

If you define the BB_WITH_CEREAL macro, json can be used as a saving format in the middle.

If you use the Python version, just import binarybrain

Please refer to samples for usage.