Deep learning framework by BAIR

Created by
Yangqing Jia
Lead Developer
Evan Shelhamer

Debian Installation

Caffe packages are available for several Debian versions, as shown in the following chart:

Your Distro     |  CPU_ONLY  |  CUDA  |     Alias
Debian/stable   |     ✘      |   ✘    | Debian Jessie
Debian/testing  |     ✔      |   ✔    | Debian Stretch/Sid
Debian/unstable |     ✔      |   ✔    | Debian Sid

Last update: 2017-02-01

Binary installation with APT

Apart from the installation methods based on source, Debian/unstable and Debian/testing users can install pre-compiled Caffe packages from the official archive.

Make sure that your /etc/apt/sources.list contains contrib and non-free sections if you want to install the CUDA version, for instance:

deb sid main contrib non-free

Then we update APT cache and directly install Caffe. Note, the cpu version and the cuda version cannot coexist.

$ sudo apt update
$ sudo apt install [ caffe-cpu | caffe-cuda ]
$ caffe                                              # command line interface working
$ python3 -c 'import caffe; print(caffe.__path__)'   # python3 interface working

These Caffe packages should work for you out of box.

Customizing caffe packages

Some users may need to customize the Caffe package. The way to customize the package is beyond this guide. Here is only a brief guide of producing the customized .deb packages.

Make sure that there is a dec-src source in your /etc/apt/sources.list, for instance:

deb sid main contrib non-free
deb-src sid main contrib non-free

Then we build caffe deb files with the following commands:

$ sudo apt update
$ sudo apt install build-essential debhelper devscripts  # standard package building tools
$ sudo apt build-dep [ caffe-cpu | caffe-cuda ]          # the most elegant way to pull caffe build dependencies
$ apt source [ caffe-cpu | caffe-cuda ]                  # download the source tarball and extract
$ cd caffe-XXXX
[ ... optional, customizing caffe code/build ... ]
$ dch --local "Modified XXX"                             # bump package version and write changelog
$ debuild -B -j4                                         # build caffe with 4 parallel jobs (similar to make -j4)
[ ... building ...]
$ debc                                                   # optional, if you want to check the package contents
$ sudo debi                                              # optional, install the generated packages
$ ls ../                                                 # optional, you will see the resulting packages

It is a BUG if the package failed to build without any change. The changelog will be installed at e.g. /usr/share/doc/caffe-cpu/changelog.Debian.gz.

Source installation

Source installation under Debian/unstable and Debian/testing is similar to that of Ubuntu, but here is a more elegant way to pull caffe build dependencies:

$ sudo apt build-dep [ caffe-cpu | caffe-cuda ]

Note, this requires a deb-src entry in your /etc/apt/sources.list.

Compiler Combinations

Some users may find their favorate compiler doesn’t work with CUDA.

CXX compiler |  CUDA 7.5  |  CUDA 8.0  |
GCC-7        |     ?      |     ?      |
GCC-6        |     ✘      |     ✘      |
GCC-5        |     ✔ [1]  |     ✔      |
CLANG-4.0    |     ?      |     ?      |
CLANG-3.9    |     ✘      |     ✘      |
CLANG-3.8    |     ?      |     ✔      |

[1] CUDA 7.5 ‘s host_config.h must be patched before working with GCC-5.

BTW, please forget the GCC-4.X series, since its libstdc++ ABI is not compatible with GCC-5’s. You may encounter failure linking GCC-4.X object files against GCC-5 libraries. (See )



CUDNN library seems not redistributable currently. If you really want the caffe-cudnn deb packages, the workaround is to install cudnn by yourself, and hack the packaging scripts, then build your customized package.

sudo apt install caffe-cuda, apt’s dependency resolver is smart enough to deal with this.

$ sudo apt install caffe-doc
$ dpkg -L caffe-doc          (for the CPU_ONLY version)  (for the CUDA version)