Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time

Building nvcaffe

A special branch of caffe is used on TX1 which includes support for FP16.
The code is released in NVIDIA's caffe repo in the experimental/fp16 branch, located here:

1. Installing Dependencies

$ sudo apt-get update -y
$ sudo apt-get install cmake -y

# General dependencies
$ sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev \
libhdf5-serial-dev protobuf-compiler -y
$ sudo apt-get install --no-install-recommends libboost-all-dev -y

$ sudo apt-get install libatlas-base-dev -y

# Remaining Dependencies
$ sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev -y

# Python Dependencies
$ sudo apt-get install python-dev python-numpy python-skimage python-protobuf -y

The Snappy package needs a symbolic link created for Caffe to link correctly:

$ sudo ln -s /usr/lib/ /usr/lib/
$ sudo ldconfig

2. Clone nvcaffe fp16 branch

$ git clone -b experimental/fp16

This will checkout the repo to a local directory called caffe on your Jetson.

3. Setup build options

$ cd caffe
$ cp Makefile.config.example Makefile.config
$ rm -rf cmake/ CMakeLists.txt
Enable FP16:
$ sed -i 's/# NATIVE_FP16/NATIVE_FP16/g' Makefile.config
Enable cuDNN:
$ sed -i 's/# USE_CUDNN/USE_CUDNN/g' Makefile.config
Enable compute_53/sm_53:
$ sed -i 's/-gencode arch=compute_50,code=compute_50/-gencode arch=compute_53,code=sm_53 -gencode arch=compute_53,code=compute_53/g' Makefile.config
Setup header/linker paths
    INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
    INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/

    LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
    LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/aarch64-linux-gnu/hdf5/serial/
Fix HDF5 Linking Issue
$ sudo ln -s /usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/
$ sudo ln -s /usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/

4. Compiling nvcaffe

$ make -j4
$ make pycaffe
$ make distribute

5. Set environment paths

# Edit the following lines in .bashrc and then source .bashrc
export PATH=/usr/local/cuda-8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/ubuntu/caffe/build/tools
export PYTHONPATH=/home/ubuntu/caffe/python:$PYTHONPATH

6. Install iPython (optional)

$ sudo apt-get install ipython ipython-notebook python-pandas -y

6. Testing nvcaffe

$ make runtest