红联Linux门户
Linux帮助

Ubuntu 16.04 64位机上不带CUDA支持的Caffe配置编译操作过程

发布时间:2016-10-28 15:17:01来源:linux网站作者:三分地
下面介绍在Ubuntu上不带CUDA的Caffe配置编译过程(这里没有安装matlab,python,opencv):
 
1.安装BLAS:$ sudo apt-get install libatlas-base-dev
 
2.安装依赖项:$ sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev protobuf-compiler liblmdb-dev
$ sudo apt-get install  libgflags-dev libgoogle-glog-dev liblmdb-dev
 
3.下载Caffe:$ Git clone git://github.com/BVLC/caffe.git
 
4.修改 caffe目录下的Makefile.config,Makefile          
cd caffe ; 
gedit Makefile.config;  
在Makefile.config文件的第85行,添加 /usr/include/hdf5/serial/ 到 INCLUDE_DIRS,也就是把下面第一行代码改为第二行代码。
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
# Uncomment to support layers written in Python (will link against Python libs)  
# WITH_PYTHON_LAYER := 1  
# 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  
gedit Makefile;
在Makefile文件的第173行,把 hdf5_hl 和hdf5修改为hdf5_serial_hl 和 hdf5_serial,也就是把下面第一行代码改为第二行代码。
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
INCLUDE_DIRS += $(BUILD_INCLUDE_DIR) ./src ./include  
ifneq ($(CPU_ONLY), 1)  
INCLUDE_DIRS += $(CUDA_INCLUDE_DIR)  
LIBRARY_DIRS += $(CUDA_LIB_DIR)  
LIBRARIES := cudart cublas curand  
endif  
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial   
 
5.安装Caffe: $cd caffe
(1)、$ cp Makefile.config.example Makefile.config
(2)、修改Makefile.config文件:去掉注释, CPU_ONLY:= 1
(3)、$ make all
(4)、$ make test
(5)、$ make runtest
说明:1.make all步骤出现错误
./include/caffe/util/hdf5.hpp:6:18: fatal error: hdf5.h: No such file or directory
解决方法如步骤4
2.编译带CUDA支持的Caffe与上面的步骤完全一致,只要把CPU_ONLY:=1注释掉即可。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/25482.html