Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caffe didn't see hdf5.h when compiling

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:

  • Update and upgrade my Ubuntu Server

  • Install Python 2.7

  • Having all of the dependencies base on http://caffe.berkeleyvision.org/install_apt.html

  • Run cp cp Makefile.config.example Makefile.config

  • Uncomment cpu_only = 1 in Makefile.config

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
like image 477
kelvin Avatar asked May 03 '16 14:05

kelvin


4 Answers

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.

like image 116
alfakini Avatar answered Oct 08 '22 00:10

alfakini


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/"
like image 44
loretoparisi Avatar answered Oct 08 '22 01:10

loretoparisi


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.

like image 4
iparjono Avatar answered Oct 08 '22 02:10

iparjono


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/"
like image 3
HimalayanCoder Avatar answered Oct 08 '22 01:10

HimalayanCoder