sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler -y
sudo apt-get install --no-install-recommends libboost-all-dev -y
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev -y
sudo apt-get install python-dev -y
下载caffe源码
git clone https://github.com/BVLC/caffe.git
修改编译配置文件:
cd caffe
复制示例文件为编译配置文件:
nano Makefile.config
GPU版:将#USE_CUDNN := 1 修改成: USE_CUDNN := 1
将# Whatever else you find you need goes here.下面的
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
修改为:
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial
打开makefile文件,做如下修改:
将:NVCCFLAGS +=-ccbin=$(CXX) -Xcompiler-fPIC $(COMMON_FLAGS)
替换为:
NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
make test -j20
make runtest -j20
echo export CAFFE_ROOT=/home/$USER/caffe >>~/.bashrc
echo export PYTHONPATH=/home/$USER/caffe/python:$PYTHONPATH >> ~/.bashrc
source ~/.bashrc
mnist测试
cd caffe
sh data/mnist/get_mnist.sh
sh examples/mnist/create_mnist.sh
time sh examples/mnist/train_lenet.sh
得到:
/usr/local/lib/python2.7/dist-packages/numpy/core/include
在Makefile.config找到PYTHON_INCLUDE,
PYTHON_INCLUDE := /usr/include/python2.7 \
再make pycaffe就ok了