Ubuntu 15.04: Compile Caffe with CUDA/cuDNN

Clone

git clone https://github.com/BVLC/caffe.git
cd caffe

Install prerequisites

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install python-dev 
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

compilation

make all
# or if you have 8-virutal-core cpus
make all -j8

Adding to Environment

# sudo vi /etc/profile
export PYTHONPATH=/your/path/to/caffe/python:$PYTHONPATH$

Python Dependence

sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython ipython

Troubleshooting

hdf5.h

src/caffe/layers/hdf5_output_layer.cpp:3:18: fatal error: hdf5.h: No such file or directory
 #include "hdf5.h"
                  ^
compilation terminated.
Makefile:575: recipe for target '.build_release/src/caffe/layers/hdf5_output_layer.o' failed
make: *** [.build_release/src/caffe/layers/hdf5_output_layer.o] Error 1
make: *** Waiting for unfinished jobs....
^X^CMakefile:575: recipe for target '.build_release/src/caffe/layers/window_data_layer.o' failed
make: *** [.build_release/src/caffe/layers/window_data_layer.o] Interrupt
Makefile:575: recipe for target '.build_release/src/caffe/layer.o' failed
make: *** [.build_release/src/caffe/layer.o] Interrupt

To solve,

#in Makefile.config:

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/

lhdf5_hl

/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5
collect2: error: ld returned 1 exit status
Makefile:566: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1

To solve,

cd /usr/lib/x86_64-linux-gnu
sudo ln -s libhdf5_serial.so.8.0.2 libhdf5.so
sudo ln -s libhdf5_serial_hl.so.8.0.2 libhdf5_hl.so
  1. http://askubuntu.com/questions/629654/building-caffe-failed-to-see-hdf5-h
  2. http://caffe.berkeleyvision.org/install_apt.html
  3. http://caffe.berkeleyvision.org/installation.html#compilation
  4. https://github.com/BVLC/caffe/issues/2690
  5. https://github.com/NVIDIA/DIGITS/issues/156

你可能感兴趣的:(caffe,ubuntu)