安装caffe碰到的坑

来源:互联网 发布:3.0录音软件 编辑:程序博客网 时间:2024/06/05 02:41

解决办法是依据出现错误的顺序而给出的,为了方便,可以直接先执行所有解决办法后再安装caffe。

1. ./include/caffe/common.hpp:5:27: fatal error: gflags/gflags.h: No such file or directory

解决办法:sudo apt-get install libgflags-dev

2. ./include/caffe/util/mkl_alternate.hpp:14:19: fatal error: cblas.h: No such file or directory

解决办法:sudo apt-get install libblas-dev

3. ./include/caffe/util/hdf5.hpp:6:18: fatal error: hdf5.h: No such file or directory

解决办法:在Makefile.config找到以下行并添加蓝色部分

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

4. ./include/caffe/util/db_lmdb.hpp:8:18: fatal error: lmdb.h: No such file or directory

解决办法:sudo apt install liblmdb-dev

5. /usr/bin/ld: cannot find -lcblas
    /usr/bin/ld: cannot find -latlas

解决办法:sudo apt install libatlas-base-dev

6. caffe /usr/bin/ld: 找不到 -lhdf5_hl

打开Makefile,将第181行的:

LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hlhdf5
      改为:
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs
      这里的改动是为了避免出现hdf5.h错误。
7. caffe 找不到hdf5_hl
laiyuanyu http://blog.csdn.net/autocyz/article/details/51783857//重要的一项# Whatever else you find you need goes here.下面的INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/includeLIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib修改为:INCLUDE_DIRS :=  $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serialLIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial//这是因为ubuntu16.04的文件包含位置发生了变化,尤其是需要用到的hdf5的位置,所以需要更改这一路径
cd /usr/lib/x86_64-linux-gnu\\然后根据情况执行下面两句:sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.sosudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so7.python/caffe/_caffe.cpp:1:52: fatal error: Python.h: No such file or directory #include <Python.h>  // NOLINT(build/include_alpha)

遇到此类问题基本是caffe找不到python,因此在make py之前反复确认下anaconda或python所在目录是否存在。

因此需要修改。

本人一直遇到的问题就是因为anaconda安装后 默认的名字为 anaconda2 8.ImportError: /home/meyer/anaconda2/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/meyer/cz/caffe-master/python/caffe/../../build/lib/libcaffe.so.1.0.0)http://blog.csdn.net/lwgkzl/article/details/77658269

原创粉丝点击