#首先我们需要安装Ubuntu16.04,傻瓜式操作。
#系统安装完成后,打开命令行控制台,输入以下命令,安装基本依赖(General dependencies)。
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
注意:由于网络情况的不同,一次安装可能不能全部安装成功,重复输入上述命令,再次安装(本人用了两次),这里建议大家一次安装一个软件包,便于弄清是那个未安装成功,以节省时间。
#安装ATLAS,输入下述命令:
sudo apt-get install libatlas-base-dev
#安装剩余依赖:
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
#下载Caffe:
sudo apt-get install git
git clone https://github.com/BVLC/caffe.git
#修改Makefile.config:
cd caffe
cp Makefile.config.example Makefile.config
gedit Makefile.config
找到#CPU_ONLY := 1,取消注释(我们设置为CPU模式)
找到
# Whatever else you find you need goes here.
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/hdf5/serial
修改为
# Whatever else you find you need goes here.
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/hdf5/serial
#进行编译
make all
make test
make runtest
#耐心等待编译完成
到此为止,Caffe就安装完成了。尽情使用吧!
错误1:
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5
collect2: error: ld returned 1 exit status
Makefile:572:recipe for target ‘.build_release/lib/libcaffe.so.1.0.0’ failed
make: * [.build_release/lib/libcaffe.so.1.0.0] Error 1
解决方法:
In your Makefile.config change:(该空格的地方一定要有空格)
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/hdf5/serial
Please note that the path may vary depending on your OS.