【问题标题】:Caffe didn't see hdf5.h when compilingCaffe 编译时没有看到 hdf5.h
【发布时间】:2016-08-28 16:43:52
【问题描述】:

在 Python 上安装 Caffe 深度学习框架时遇到问题:

当我在 caffe 目录运行make 命令时,它会说

hdf5.h:没有那个目录

我做过的步骤:

如果有人可以帮助我,我将不胜感激。

错误信息:

CXX src/caffe/util/hdf5.cpp
in file include from src/caffe/util/hdf5.cpp:1:0:
./include/caffe/util/hdf5.hpp:6:18: fatal error: hdf5.h: No such file or directory
compilation terminated 

Makefile:572 recipe for target '.build_release/src/caffe/util/hdf5.o'       
failed Make:*** [.build_release/src/caffe/util/hdf5.o] Error 1

【问题讨论】:

  • 欢迎来到 SO。请不要发布屏幕截图,而是将错误消息复制粘贴(并格式化)到您的问题:这样搜索引擎将来可以更好地找到此线程。
  • 你安装hdf5了吗?看caffe.berkeleyvision.org/install_apt.htmlsudo apt-get install libhdf5-serial-dev
  • 抱歉,我是新人,我会更改屏幕截图。谢谢你通知我。是的,我已经安装了 hdf5。
  • 您的系统上是否有hdf5.h?尝试使用locate hdf5.h 之类的命令找出它的位置,然后在此处发布。
  • 嗨,我尝试按照您在我的 ubuntu 终端中的建议写 locate hdf5.h,但没有任何反应。所以,我运行另一个评论find ~/ -type f -name "hdf5.h" 结果是/home/kelvin/opencv-3.1.0/modules/flann/include/opencv2/flann/hdf5.h。谢谢

标签: python deep-learning caffe


【解决方案1】:

它在 Ubuntu16.04 LTS 上对我不起作用。

所以我不得不

sudo apt-get install libhdf5-10
sudo apt-get install libhdf5-serial-dev
sudo apt-get install libhdf5-dev
sudo apt-get install libhdf5-cpp-11
find /usr -iname "*hdf5.h*"
/usr/include/hdf5/serial/hdf5.h

现在做这个

export CPATH="/usr/include/hdf5/serial/"

【讨论】:

    【解决方案2】:

    RHEL7 上,我厌倦了寻找特定的 hdf5 RPM 并运行:

    sudo yum install *hdf5*
    

    这些是我所拥有的:

    hdf5-openmpi3-static-1.8.12-11.el7.x86_64
    hdf5-1.8.12-11.el7.x86_64
    hdf5-openmpi-static-1.8.12-11.el7.x86_64
    hdf5-openmpi3-devel-1.8.12-11.el7.x86_64
    hdf5-openmpi3-1.8.12-11.el7.x86_64
    hdf5-mpich-devel-1.8.12-11.el7.x86_64
    hdf5-devel-1.8.12-11.el7.x86_64
    hdf5-openmpi-devel-1.8.12-11.el7.x86_64
    hdf5-mpich-static-1.8.12-11.el7.x86_64
    hdf5-mpich-1.8.12-11.el7.x86_64
    hdf5-openmpi-1.8.12-11.el7.x86_64
    

    感谢@loretoparisi,我能够找出丢失的头文件在哪里,问题就消失了。

    $ find /usr -iname "*hdf5.h*"
    /usr/include/openmpi-x86_64/hdf5.h
    /usr/include/hdf5.h
    /usr/include/mpich-x86_64/hdf5.h
    /usr/include/openmpi3-x86_64/hdf5.h
    

    【讨论】:

      【解决方案3】:

      此解决方案在 Ubuntu16.04LTS 上对我有用

      sudo apt-get install libhdf5-10
      sudo apt-get install libhdf5-serial-dev
      sudo apt-get install libhdf5-dev
      sudo apt-get install libhdf5-cpp-11
      find /usr -iname "*hdf5.h*"
      /usr/include/hdf5/serial/hdf5.h
      export CPATH="/usr/include/hdf5/serial/"
      

      【讨论】:

      • 也为我工作!
      • 为我工作了三个!
      • 只是 sudo apt-get install libhdf5-10 libhdf5-serial-dev 为我工作
      【解决方案4】:

      我经历过的另一个案例:

      我使用的是 Ubuntu 14.04 并安装 hdf5-1.10.0

      我发现hdf5.h 位于/usr/local/hdf5/include。因此,我修改了Makefile.config 文件,将该位置添加到INCLUDE_DIRS

      # Whatever else you find you need goes here.
      INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include \
                          /usr/local/hdf5/include
      

      我没有重命名Makefile 中的任何内容。效果很好。

      【讨论】:

        【解决方案5】:

        您的 Ubuntu 安装版本是什么?尝试这个。在您的Makefile.config 中尝试将/usr/include/hdf5/serial/ 附加到INCLUDE_DIRS

        --- INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
        +++ INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
        

        并在Makefile 中将hdf5_hlhdf5 重命名为hdf5_serial_hlhdf5_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
        

        更多关于错误修复here

        【讨论】:

        • 对不起,我的回复晚了,谢谢你的帮助我已经通过将我的 hdf5 移动到目录来解决问题。
        • 谢谢。这节省了我的时间!
        • 这是对我有用的解决方案!非常感谢!
        • 这个答案确实是最好的解决方案(即,而不是移动 hdf5 目录。)@kelvin:你能把这个答案标记为正确吗?
        • 我刚刚添加了 'LIBRARIES += ' 字符串。我没有,它似乎工作。
        猜你喜欢
        • 2018-04-08
        • 2017-07-13
        • 1970-01-01
        • 2017-02-24
        • 1970-01-01
        • 2016-02-19
        • 2016-02-14
        • 1970-01-01
        相关资源
        最近更新 更多