fatal error: hdf5.h: No such file or directory


If you get “fatal error: hdf5.h: No such file or directory” while trying to compile Caffe on Linux that can be due to different reasons.

First, you need to make sure the HDF5 packages are installed. If they are not installed, you can install them easily using

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

If it’s installed, then probably you need to provide the path to the compiler.
GCC looks in several different places for headers. On a normal Unix system, if you do not instruct it otherwise, it will look for headers requested with #include in:


You can find out the path of the hdf5.h using

find /usr -iname "*hdf5.h*"

usually you would find something like

then you can just simply type

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

Make will be able to find hdf5.h now.