下载caffe的安装包
git clone git://github.com/BVLC/caffe.git
$ cd caffe
$ cp Makefile.config.example Makefile.config (复制一份Makefile.config文件)
$ make pycaffe
$ make all
$ make run
$ make test
测试
$ python
$ import caffe
问题记录
(1)google protobuf 支持2.6
查询 终端输入 protoc --version
libprotoc 2.5.0
最开始安装的3.3 不支,重新安装
(2)make all 出现错误
./include/caffe/util/hdf5.hpp:6:18: fatal error: hdf5.h: No such file or directory
caffe路径下输入
sudo find / -name hdf5.h
找到 find: `/run/user/1000/gvfs': 权限不够
/home/wy/下载/opencv-3.3.0/modules/flann/include/opencv2/flann/hdf5.h
/usr/local/include/opencv2/flann/hdf5.h
/usr/include/opencv2/flann/hdf5.h
/usr/include/hdf5/serial/hdf5.h
在makefile.config文件中
# 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(下个错误要用的)
再执行一遍上述命令,继续报错,这次是/usr/bin/ld: cannot find -lhdf5
于是同上面一个处理 去找libhdf5.so
配置文件改为:
再执行一遍上述命令,继续报错,这次是/usr/bin/ld: cannot find -lhdf5
于是同上面一个处理 去找libhdf5.so
配置文件改:
再执行一遍上述命令,继续报错,这次是/usr/bin/ld: cannot find -lhdf5
于是同上面一个处理 去找libhdf5.so
配置文件改为:
LIBRARY_DIRS := $(PYTHON_LIB) /usr/lib/x86_64-linux-gnu/hdf5/serial \
/usr/local/lib /usr/lib
- 1
- 2
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/include/hdf5/serial \
/usr/local/include
最终修改的是:
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 clean
make pycaffe
make all
make run
make test
(3)对opencv不支持
不保存不用修改
配置Makefile文件(实现对OpenCV3.x的支持)
# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1
LIBRARIES += opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs
还有几个比较好的问题回答
https://github.com/BVLC/caffe/issues/2348#issuecomment-95156848
https://github.com/BVLC/caffe/issues/2092
参考
https://blog.csdn.net/fengbingchun/article/details/72318839
https://blog.csdn.net/weixin_37911283/article/details/70505145
https://blog.csdn.net/zt_1995/article/details/56283249