31

I am having trouble when installing Caffe Deep Learning Framework on Python:

When I run make command at caffe directory, it says

hdf5.h:no such directory

The steps I have done:

I will be grateful if someone can help me.

Error message:

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
Lundin
  • 195,001
  • 40
  • 254
  • 396
kelvin
  • 321
  • 1
  • 3
  • 6
  • 2
    welcome to SO. please do not post screenshots, but rather copy-paste (and format) the error message to your question: this way search engines can better locate this thread in the future. – Shai May 03 '16 at 15:07
  • 2
    have you installed hdf5? look at http://caffe.berkeleyvision.org/install_apt.html: `sudo apt-get install libhdf5-serial-dev` – Shai May 03 '16 at 15:10
  • 1
    oh sorry about that i'm new, i will change the screenshots. thank you for notifying me. yes i already installed hdf5. – kelvin May 05 '16 at 02:24
  • 1
    Do you have `hdf5.h` on your system somewhere? Try a command like `locate hdf5.h` to find out where it is, and post that here. – John Zwinck May 05 '16 at 02:58
  • 1
    hi, i try to write `locate hdf5.h` as you suggest in my ubuntu terminal but nothing happen. so, i run another comment `find ~/ -type f -name "hdf5.h"` an the result is `/home/kelvin/opencv-3.1.0/modules/flann/include/opencv2/flann/hdf5.h`. Thank you – kelvin May 05 '16 at 05:25

5 Answers5

64

What is the version of your Ubuntu install? Try this. In your Makefile.config try to append /usr/include/hdf5/serial/ to INCLUDE_DIRS:

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

and rename hdf5_hl and hdf5 to hdf5_serial_hl and hdf5_serial in the Makefile:

--- 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

More about the bug fix here.

alfakini
  • 4,635
  • 2
  • 26
  • 35
30

This solution worked for me on the 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/"
loretoparisi
  • 15,724
  • 11
  • 102
  • 146
4

Another case I've experienced with:

I was using Ubuntu 14.04 and installing hdf5-1.10.0.

I found hdf5.h was located in /usr/local/hdf5/include. Thus, I modified Makefile.config file by adding that location to INCLUDE_DIRS.

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

I didn't rename anything in Makefile. It worked fine.

iparjono
  • 361
  • 1
  • 2
  • 9
4

It did not work for me on Ubuntu16.04 LTS.

So I had to

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

Now do this

export CPATH="/usr/include/hdf5/serial/"
HimalayanCoder
  • 9,630
  • 6
  • 59
  • 60
1

On RHEL7, I got tired of hunting for specific hdf5 RPMs and ran:

sudo yum install *hdf5*

and these are what I have:

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

Thanks to @loretoparisi, I was able to figure out where I had the header file I was missing and the problem went away.

$ 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
Srini
  • 1,626
  • 2
  • 15
  • 25