Skip to content

Minimal runtime core of Caffe, Forward only, GPU support and Memory efficiency.

License

Notifications You must be signed in to change notification settings

yang53/mini-caffe

 
 

Repository files navigation

Mini-Caffe

Build Status Build status

Minimal runtime core of Caffe. This repo is aimed to provide a minimal C++ runtime core for those want to Forward a Caffe model.

What can Mini-Caffe do?

Mini-Caffe only depends on OpenBLAS and protobuf which means you can't train model with Mini-Caffe. It also only supports Forward function which means you can't apply models like nerual art style transform that uses Backward function.

Build on Windows

You need a VC compiler to build Mini-Caffe. Visual Studio 2013 Community should be fine. You can download from here.

OpenBLAS

OpenBLAS library is already shipped with the source code, we don't need to compile it. If you want, you could download other version from here. v0.2.14 is used for Mini-Caffe.

protobuf

protobuf is a git submodule in Mini-Caffe, we need to fetch the source code and compile it.

$ git submodule update --init
$ cd 3rdparty/src/protobuf/cmake
$ mkdir build
$ cd build
$ cmake .. -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -G "Visual Studio 12 2013 Win64"

Use protobuf.sln to compile Debug and Release version.

With these two libraries, we can compile Mini-Caffe now. Copy protobuf's include headers and libraries. Generate caffe.pb.h and caffe.pb.cc.

$ copydeps.bat
$ generatepb.bat
$ mkdir build
$ cd build
$ cmake .. -G "Visual Studio 12 2013 Win64"

Use mini-caffe.sln to compile it.

Build on Linux

Install OpenBLAS and protobuf library through system package manager. Or you can compile OpenBLAS and protobuf by yourself. Then build Mini-Caffe.

$ sudo apt install libopenblas-dev libprotobuf-dev protobuf-compiler
$ ./generatepb.sh
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Release
$ make -j4

If you don't use Ubuntu, then you may need to install OpenBLAS and protobuf through your system package manager if any.

Build for Android

Mini-Caffe now can be cross compiled for Android platform, checkout the document here.

With CUDA and CUDNN support

Install CUDA8 and cuDNN5.1 in your system, then we can compile Mini-Caffe with GPU support. Run CMake command below.

$ cmake .. -DUSE_CUDA=ON -DUSE_CUDNN=ON

With Java support

Install Java and set environment variable JAVA_HOME. Run CMake command below.

$ cmake .. -DUSE_JAVA=ON

With Python support

checkout Python API here, install package via python setup.py install.

How to use Mini-Caffe

To use Mini-Caffe as a library, you may refer to example.

How to profile your network

The Profiler in Mini-Caffe can help you profile your network performance, see docs here.

About

Minimal runtime core of Caffe, Forward only, GPU support and Memory efficiency.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 67.1%
  • Cuda 16.5%
  • Protocol Buffer 5.9%
  • CMake 2.8%
  • Python 2.7%
  • C 2.5%
  • Other 2.5%