安装caffe碰到的坑(各种.so未找到)

./include/caffe/common.hpp:4:32: fatal error: boost/shared_ptr.hpp: 没有那个文件或目录

所有类似于上面的错误,都可以用如下格式来解决:

解决方案:出现该错误的原因是少了依赖。

在命令行输入:

$ sudo apt-get install --no-install-recommends libboost-all-dev

即可解决。

 

 

解决办法是依据出现错误的顺序而给出的,为了方便,可以直接先执行所有解决办法后再安装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/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
修改为:
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 /usr/lib/x86_64-linux-gnu/hdf5/serial
//这是因为ubuntu16.04的文件包含位置发生了变化,尤其是需要用到的hdf5的位置,所以需要更改这一路径


cd /usr/lib/x86_64-linux-gnu

 

查看某文件的所有软链接:ls -al *libhdf5*

 


\\然后根据情况执行下面两句:
sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so
sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so
7.
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

posted @ 2019-12-24 12:37  小丑_jk  阅读(2929)  评论(0编辑  收藏  举报