clCaffe: an OpenCL based Caffe for Intel Gen Graphics platforms.
Clone or download
Pull request Compare This branch is 1465 commits ahead, 238 commits behind BVLC:master.
Zhigang Gong
Zhigang Gong Fix a build error when disable USE_GREENTEA.
Signed-off-by: Zhigang Gong <>
Latest commit 2df19ae Feb 26, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add Github issue template to curb misuse. Nov 3, 2016
android android compilation support Feb 2, 2017
cmake Simplifies cmake code for searching for boost python3 Nov 24, 2017
data Added some data files for yolo. Jul 4, 2017
docker Merge branch 'master' of Feb 9, 2017
docs Merge branch 'master' of Mar 3, 2017
examples Links python libraries to tools and examples when Python is being used. Nov 24, 2017
include/caffe Fix a build error when disable USE_GREENTEA. Feb 26, 2018
matlab Merge branch 'master' of Feb 17, 2017
models Added mobileNet classication network Aug 4, 2017
python Fixed an bug on pycaffe binding lacking SetDevices definition for CPU… Dec 15, 2017
scripts Add ISAAC support on Windows. Aug 18, 2017
src Only set the -ifp obuild option if the compiler supports it. Dec 22, 2017
tools Fixed a layer fusion tool bug. Dec 5, 2017
.Doxyfile update doxygen config to stop warnings Sep 3, 2014
.gitattributes Add support for windows build Feb 11, 2016
.gitignore add VOC0712 sample solver and model Jun 29, 2017
.travis.yml Stop setting cache timeout in TravisCI Jul 15, 2016
CMakeLists.txt Allows tools to be excluded from build Nov 24, 2017 [docs] add which will appear on GitHub new Issue/PR p… Jul 30, 2015 clarify the license and copyright terms of the project Aug 7, 2014 installation questions -> caffe-users Oct 19, 2015
LICENSE update LICENSE Jun 29, 2017
Makefile fix a few minor issues Jun 29, 2017
Makefile.config.example change Makefile.config.example Jun 29, 2017 Add Intel security notice to readme. Dec 19, 2017
appveyor.yml Merge Feb 2, 2017
caffe.cloc [fix] stop cloc complaint about cu type Sep 4, 2014 Updated MergeCrop layer parameters. Jul 18, 2015

OpenCL Caffe

This is an experimental, community-maintained branch led by Fabian Tschopp (@naibaf7). It is a work-in-progress.

For error reports, please run and include the result of ./build/test/test_all.testbin --gtest_filter=*OpenCLKernelCompileTest* X where X is the OpenCL device to test (i.e. 0). This test is available after a build with make all, make runtest.

This branch of Caffe contains an OpenCL backend and additional layers for fast image segmentation. This work is partially supported by:

  • AMD
  • HHMI Janelia
  • UZH, INI
  • ETH Zurich
  • Intel

For a C++ frontend and models to use for image segmentation with this fork, see:

OpenCL Backend

The backend is supposed to work with all vendors. Note however there may be problems with provided by nVidia. It is therefore recommended to install another OpenCL implementation after installing nVidia drivers. Possibilities are:

Technical Report

Available on arXiv:

Windows Caffe

This is an experimental, communtity based branch led by Guillaume Dumont (@willyd). It is a work-in-progress.

This branch of Caffe ports the framework to Windows.

Travis Build Status Travis (Linux build)

Build status AppVeyor (Windows build)

Prebuilt binaries

Prebuilt binaries can be downloaded from the latest CI build on appveyor for the following configurations:

Windows Setup


  • Visual Studio 2013 or 2015
  • CMake 3.4 or higher (Visual Studio and Ninja generators are supported)

Optional Dependencies

  • Python for the pycaffe interface. Anaconda Python 2.7 or 3.5 x64 (or Miniconda)
  • Matlab for the matcaffe interface.
  • CUDA 7.5 or 8.0 (use CUDA 8 if using Visual Studio 2015)
  • cuDNN v5

We assume that cmake.exe and python.exe are on your PATH.

Configuring and Building Caffe

The fastest method to get started with caffe on Windows is by executing the following commands in a cmd prompt (we use C:\Projects as a root folder for the remainder of the instructions):

C:\Projects> git clone
C:\Projects> cd caffe
C:\Projects\caffe> git checkout windows
:: Edit any of the options inside build_win.cmd to suit your needs
C:\Projects\caffe> scripts\build_win.cmd

The build_win.cmd script will download the dependencies, create the Visual Studio project files (or the ninja build files) and build the Release configuration. By default all the required DLLs will be copied (or hard linked when possible) next to the consuming binaries. If you wish to disable this option, you can by changing the command line option -DCOPY_PREREQUISITES=0. The prebuilt libraries also provide a prependpath.bat batch script that can temporarily modify your PATH envrionment variable to make the required DLLs available.

Below is a more complete description of some of the steps involved in building caffe.

Install the caffe dependencies

By default CMake will download and extract prebuilt dependencies for your compiler and python version. It will create a folder called libraries containing all the required dependencies inside your build folder. Alternatively you can build them yourself by following the instructions in the caffe-builder README.

Use cuDNN

To use cuDNN the easiest way is to copy the content of the cuda folder into your CUDA toolkit installation directory. For example if you installed CUDA 8.0 and downloaded you should copy the content of the cuda directory to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0. Alternatively, you can define the CUDNN_ROOT cache variable to point to where you unpacked the cuDNN files e.g. C:/Projects/caffe/cudnn-8.0-windows10-x64-v5.1/cuda. For example the command in scripts/build_win.cmd would become:

      -DBLAS=Open ^
      -DBUILD_python:BOOL=%BUILD_PYTHON% ^
      -DBUILD_python_layer:BOOL=%BUILD_PYTHON_LAYER% ^
      -DBUILD_matlab:BOOL=%BUILD_MATLAB% ^
      -DCUDNN_ROOT=C:/Projects/caffe/cudnn-8.0-windows10-x64-v5.1/cuda ^
      -C "%cd%\libraries\caffe-builder-config.cmake" ^

Alternatively, you can open cmake-gui.exe and set the variable from there and click Generate.

Building only for CPU

If CUDA is not installed Caffe will default to a CPU_ONLY build. If you have CUDA installed but want a CPU only build you may use the CMake option -DCPU_ONLY=1.

Using the Python interface

The recommended Python distribution is Anaconda or Miniconda. To successfully build the python interface you need to install the following packages:

conda install --yes numpy scipy matplotlib scikit-image pip six

also you will need a protobuf python package that is compatible with pre-built dependencies. This package can be installed this way:

conda install --yes --channel willyd protobuf==3.1.0

If Python is installed the default is to build the python interface and python layers. If you wish to disable the python layers or the python build use the CMake options -DBUILD_python_layer=0 and -DBUILD_python=0 respectively. In order to use the python interface you need to either add the C:\Projects\caffe\python folder to your python path of copy the C:\Projects\caffe\python\caffe folder to your site_packages folder.

Using the MATLAB interface

Follow the above procedure and use -DBUILD_matlab=ON. Change your current directory in MATLAB to C:\Projects\caffe\matlab and run the following command to run the tests:

>> caffe.run_tests()

If all tests pass you can test if the classification_demo works as well. First, from C:\Projects\caffe run python scripts\ models\bvlc_reference_caffenet to download the pre-trained caffemodel from the model zoo. Then change your MATLAB directory to C:\Projects\caffe\matlab\demo and run classification_demo.

Using the Ninja generator

You can choose to use the Ninja generator instead of Visual Studio for faster builds. To do so, change the option set WITH_NINJA=1 in the build_win.cmd script. To install Ninja you can download the executable from github or install it via conda:

> conda config --add channels conda-forge
> conda install ninja --yes

When working with ninja you don't have the Visual Studio solutions as ninja is more akin to make. An alternative is to use Visual Studio Code with the CMake extensions and C++ extensions.

Building a shared library

CMake can be used to build a shared library instead of the default static library. To do so follow the above procedure and use -DBUILD_SHARED_LIBS=ON. Please note however, that some tests (more specifically the solver related tests) will fail since both the test exectuable and caffe library do not share static objects contained in the protobuf library.


Should you encounter any error please post the output of the above commands by redirecting the output to a file and open a topic on the caffe-users list mailing list.

Previous Visual Studio based build

The previous windows build based on Visual Studio project files is now deprecated. However, it is still available in the windows folder. Please see the in there for details.

Known issues

  • The GPUTimer related test cases always fail on Windows. This seems to be a difference between UNIX and Windows.
  • Shared library (DLL) build will have failing tests.
  • Shared library build only works with the Ninja generator

Further Details

Refer to the BVLC/caffe master branch README for all other details such as license, citation, and so on.

SSD: Single Shot MultiBox Detector

Build Status License

By Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed, Cheng-Yang Fu, Alexander C. Berg.


SSD is an unified framework for object detection with a single network. You can use the code to train/evaluate a network for object detection task. For more details, please refer to our arXiv paper and our slide.

SSD Framework

System VOC2007 test mAP FPS (Titan X) Number of Boxes Input resolution
Faster R-CNN (VGG16) 73.2 7 ~6000 ~1000 x 600
YOLO (customized) 63.4 45 98 448 x 448
SSD300* (VGG16) 77.2 46 8732 300 x 300
SSD512* (VGG16) 79.8 19 24564 512 x 512

SSD results on multiple datasets

Note: SSD300* and SSD512* are the latest models. Current code should reproduce these results.

Citing SSD

Please cite SSD in your publications if it helps your research:

  title = {{SSD}: Single Shot MultiBox Detector},
  author = {Liu, Wei and Anguelov, Dragomir and Erhan, Dumitru and Szegedy, Christian and Reed, Scott and Fu, Cheng-Yang and Berg, Alexander C.},
  booktitle = {ECCV},
  year = {2016}


  1. Installation
  2. Preparation
  3. Train/Eval
  4. Models


  1. Get the code. We will call the directory that you cloned Caffe into $CAFFE_ROOT
git clone
cd caffe
git checkout ssd
  1. Build the code. Please follow Caffe instruction to install all necessary packages and build it.
# Modify Makefile.config according to your Caffe installation.
cp Makefile.config.example Makefile.config
make -j8
# Make sure to include $CAFFE_ROOT/python to your PYTHONPATH.
make py
make test -j8
make runtest
# If you have multiple GPUs installed in your machine, make runtest might fail. If so, try following:
export CUDA_VISIBLE_DEVICES=0; make runtest


  1. Download fully convolutional reduced (atrous) VGGNet. By default, we assume the model is stored in $CAFFE_ROOT/models/VGGNet/

  2. Download VOC2007 and VOC2012 dataset. By default, we assume the data is stored in $HOME/data/

# Download the data.
cd $HOME/data
# Extract the data.
tar -xvf VOCtrainval_11-May-2012.tar
tar -xvf VOCtrainval_06-Nov-2007.tar
tar -xvf VOCtest_06-Nov-2007.tar
  1. Create the LMDB file.
# Create the trainval.txt, test.txt, and test_name_size.txt in data/VOC0712/
# You can modify the parameters in if needed.
# It will create lmdb files for trainval and test with encoded original image:
#   - $HOME/data/VOCdevkit/VOC0712/lmdb/VOC0712_trainval_lmdb
#   - $HOME/data/VOCdevkit/VOC0712/lmdb/VOC0712_test_lmdb
# and make soft links at examples/VOC0712/


  1. Train your model and evaluate the model on the fly.
# It will create model definition files and save snapshot models in:
#   - $CAFFE_ROOT/models/VGGNet/VOC0712/SSD_300x300/
# and job file, log file, and the python script in:
#   - $CAFFE_ROOT/jobs/VGGNet/VOC0712/SSD_300x300/
# and save temporary evaluation results in:
#   - $HOME/data/VOCdevkit/results/VOC2007/SSD_300x300/
# It should reach 77.* mAP at 120k iterations.
python examples/ssd/

If you don't have time to train your model, you can download a pre-trained model at here.

  1. Evaluate the most recent snapshot.
# If you would like to test a model you trained, you can do:
python examples/ssd/
  1. Test your model using a webcam. Note: press esc to stop.
# If you would like to attach a webcam to a model you trained, you can do:
python examples/ssd/

Here is a demo video of running a SSD500 model trained on MSCOCO dataset.

  1. Check out examples/ssd_detect.ipynb or examples/ssd/ssd_detect.cpp on how to detect objects using a SSD model. Check out examples/ssd/ on how to plot detection results output by ssd_detect.cpp.

  2. To train on other dataset, please refer to data/OTHERDATASET for more details. We currently add support for COCO and ILSVRC2016. We recommend using examples/ssd.ipynb to check whether the new dataset is prepared correctly.


We have provided the latest models that are trained from different datasets. To help reproduce the results in Table 6, most models contain a pretrained .caffemodel file, many .prototxt files, and python scripts.

  1. PASCAL VOC models:

  2. COCO models:

  3. ILSVRC models:

[1]We use examples/convert_model.ipynb to extract a VOC model from a pretrained COCO model.

Windows support for Intel Gen platform


  • Visual Studio 2015 - Choose to install visual c++ and Windows SDK during the installation.
  • CMake
  • ViennaCL - put it in the same directory as Caffe's source code.
  • Python 2.7
  • ISAAC - Please see below detail instructions
  • Latest Intel Graphics Driver and OpenCL SDK at

Open a Git Bash console on Windows and do the following instructions to build both dlfcn-win32 and isaac. Please put both dlfcn-win32 and isaac at the same directory as caffe.

git clone
cd dlfcn-win32
cmake -G "Visual Studio 14 2015 Win64" .
cmake --build . --config Release
cd ..
git clone
mkdir -p isaac/build
cd isaac/build
cmake -G "Visual Studio 14 2015 Win64" ..
cmake --build . --config Release

How to build

Open a Windows command prompt console (cmd)
cd caffe_source_dir

Please be noted that, after the building finished successfully, before you try to run the application, you need to copy the dl.dll (dlfcn) and isaac.dll (isaac) into the same directory or put them into a system directory.

Intel OTC Security Notice

Please report any security issues following the procedure described in