Brewing CAFFE for Deep Learning
Although CAFFE has a good [compliation insturction][comp] on Berkeley’s BLVC project website, you may still encounter some issues during compilation. This post records some issues I have encountered, which might the same issue for you.
Envrionment: Ubuntu 14.04, BASH. This post assumes that you have already installed pre-requistes (CUDA, cuDNN, Python, BLAS).
##Step 1: Clone down CAFFE on GitHub First, cd to the directory you want CAFFE to be installed Then, clone down CAFFE to your local machine.
##git clone git clone https://github.com/BVLC/caffe.git The Makefile.config (in $CAFFE root directory) contains some configuration variables which is used in Makefile.
##Step 2: Configure CUDA_INCLUDE_DIR When you run make all command directly, you may get errors saying that there are missing files. This maybe due to the wrong configuration of the CUDA_INCLUDE_DIR. The default in Makefile is
CUDA_INCLUDE_DIR := $(CUDA_DIR)/include where $(CUDA_DIR) is the root directory of CUDA. However, turns out the include directory under $(CUDA_DIR) does not contain some required files, like cublas_v2.h (CUDA Basic Linear Algebra Package, version 2). In fact, there is another include directory under this folder, which contains the required files. So you should set: CUDA_INCLUDE_DIR := $(CUDA_DIR)/targets/x86_64-linux/include I am not quite sure why there are two such include directories under $CUDA_DIR and what's the difference between them.
##Step 3: Compile with cuDNN accerleration <image src=”http://devblogs.nvidia.com/parallelforall/wp-content/uploads/sites/3/2014/09/cudnn_caffe_performance-289x300.png” title=’cuDNN acceleartion’ </image> cuDNN package gives you 1.3x speed boost according to [Nvidia test][NV]. To compile with cuDNN accleration, you need first install cuDNN then uncomment the USE_CUDNN := 1 flag in Makefile.config.
After that, you need to add “include path” and “library path” for cuDNN in order for the program to be able to find required include file and library for compiling and running. To do this, add the following command in Makefile, in the “# cuDNN acceleration configuration” part, line 266.
INCLUDE_DIRS +=/path/to/cudnn LIBRARY_DIRS +=/path/to/cudnn
Then you will be good to perform.
make all make test The parameter after make will be passed to Makefile to triger on some routines. After the above settings, when you do make runtest you may still encounter some probelms, which says:"missing cudnn*.so. No such file or directory." You might fee strange because you have already set the path to cudnn, why there are still such disgusting errors. Go on to next step.
Step 4: Configure cuDNN path in ~/.bashrc
The above issue is a easy fix. Just open ~/.bashrc, and add the path to cuDNN installation directory to the LD_LIBRARY_PATH variable.
export LD_LIBRARY_PATH = /path/to/cudnn:$LD_LIBRARY_PATH Then you will be able to run make runtest, and successfully compile CAFFE.
All right, hope you a good journey with CAFFE. [comp]: http://caffe.berkeleyvision.org/installation.html [NV]: http://devblogs.nvidia.com/parallelforall/accelerate-machine-learning-cudnn-deep-neural-network-library/