Makefile.config文件和caffe35环境装一样,多了去掉use cudnn=1和opencv_version=3的注释
出现错误如下:
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: 找不到 -lopencv_imgcodecs
collect2: error: ld returned 1 exit status
Makefile:582: recipe for target '.build_release/lib/libcaffe.so.1.0.0' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1
解决办法:
首先,将Makefile.config文件中OPENCV_VERSION=3注释掉,只修改USE_OPENCV: =1
修改后的结果为:
USE_OPENCV: =1
#OPENCV_VERSION=3
然后打开Makefile文件,查找“Derive include and lib directories”一节,修改“LIBRARIES +=”这一行
原来为:
LIBRARIES += opencv_core opencv_highgui opencv_imgproc
变为:
LIBRARIES += opencv_imgcodecs opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs
保存,退出
然后
make clean
make all -j8
>>> import caffe
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/drl/anaconda3/envs/caffe3/lib/python3.5/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "/home/drl/anaconda3/envs/caffe3/lib/python3.5/caffe/pycaffe.py", line 13, in <module>
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
SystemError: initialization of _caffe raised unreported exception
原因是numpy的版本问题,0xb是1.13,0xa是1.12版本
解决办法是安装1.13版本的numpy,然后运行出现:
>>> import caffe
/home/drl/anaconda3/envs/caffe3/lib/python3.5/site-packages/matplotlib/font_manager.py:280: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
'Matplotlib is building the font cache using fc-list. '
解决办法是:
sudo apt-get install libfreetype6-dev libxft-dev