Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't find hdf5.h when build caffe #156

Closed
tangshi opened this issue Jun 24, 2015 · 26 comments
Closed

can't find hdf5.h when build caffe #156

tangshi opened this issue Jun 24, 2015 · 26 comments

Comments

@tangshi
Copy link

tangshi commented Jun 24, 2015

I want to install digits on my debian jessie.
When I build caffe(NVIDIA's fork), I got errors complaining that hdf5.h could not be found.

I'm sure I had installed libhdf5-serial-dev and libhdf5-dev, and I found the header file in /usr/include/hdf5/serial and its libs in /usr/lib/x86_64-linux-gnu.

So, what's wrong? Some one help me?

The build error message show below:

(venv)➜  caffe  make all --jobs=4
CXX src/caffe/layer_factory.cpp
CXX src/caffe/util/insert_splits.cpp
CXX src/caffe/util/db.cpp
CXX src/caffe/util/upgrade_proto.cpp
In file included from src/caffe/util/upgrade_proto.cpp:10:0:
./include/caffe/util/io.hpp:8:18: fatal error: hdf5.h: no such file or directory
 #include "hdf5.h"
                  ^
compilation terminated.
Makefile:512: recipe for target '.build_release/src/caffe/util/upgrade_proto.o' failed
make: *** [.build_release/src/caffe/util/upgrade_proto.o] Error 1
make: *** 正在等待未完成的任务....
In file included from ./include/caffe/common_layers.hpp:10:0,
                 from ./include/caffe/vision_layers.hpp:10,
                 from src/caffe/layer_factory.cpp:6:
./include/caffe/data_layers.hpp:9:18: fatal error: hdf5.h: no such file or directory
 #include "hdf5.h"
                  ^
compilation terminated.
Makefile:512: recipe for target '.build_release/src/caffe/layer_factory.o' failed
make: *** [.build_release/src/caffe/layer_factory.o] Error 1
@tangshi
Copy link
Author

tangshi commented Jun 24, 2015

I solved the header file problem according to here.

But there is another problem:

/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5

so sad...

@tangshi
Copy link
Author

tangshi commented Jun 24, 2015

Lucky! I solved the second problem!

The lib names of hdf5 on debian have a postfix "serial", therefore -lhdf5 and -lhdf5_hl cannot be found.

To solve it, I created two symbolics:

cd /usr/lib/x86_64-linux-gnu
sudo ln -s libhdf5_serial.so.8.0.2 libhdf5.so
sudo ln -s libhdf5_serial_hl.so.8.0.2 libhdf5_hl.so

@chenyang-charles
Copy link

THX a lot, works for me on Ubuntu 15.04~

@dgorissen
Copy link

See also issue BVLC/caffe#2690

@minemeraj
Copy link

Thanks a lot...... worked in Ubuntu 16......

@bucketzxm
Copy link

after do the two steps @tangshi mentioned, I continued to add the following lines in MakeFile.config
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/ and
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/

@coelho-oliva
Copy link

YAY, thanks a lot! Worked on my Linux Mint 18(guess it's Sarah) too.

@jeremy-rutman
Copy link

the lbhdf5 you actually have will determine what symlink to do - so after ls /usr/lib/x86_64-linux-gnu to see what version you have, do the symlink taking that into account. (.e.g i had v10 not v8 as in post above)

$ sudo ln -s /usr/lib/x86_64-linux-gnu/libhdf5_serial.so.10 /usr/lib/x86_64-linux-gnu/libhdf5.so
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libhdf5_serial_hl.so.10 /usr/lib/x86_64-linux-gnu/libhdf5_hl.so

@r3t2
Copy link

r3t2 commented Sep 13, 2016

thank you. had the same problem.

@raditha
Copy link

raditha commented Oct 31, 2016

thank you worked for me.

@ed2k
Copy link

ed2k commented Feb 5, 2017

ubuntu 16.04
diff --git a/Makefile b/Makefile
index 65d08f7..6c6c9f3 100644
--- a/Makefile
+++ b/Makefile
@@ -178,7 +178,8 @@ ifneq ($(CPU_ONLY), 1)
LIBRARIES := cudart cublas curand
endif

-LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
+LIBRARIES += glog gflags protobuf boost_system boost_filesystem m
+LIBRARIES += hdf5_serial hdf5_serial_hl

@MartinThoma
Copy link

dacox added a commit to kinsolresearch/caffe that referenced this issue May 10, 2017
dacox added a commit to kinsolresearch/caffe that referenced this issue May 12, 2017
@collinalexbell
Copy link

collinalexbell commented May 18, 2017

Thanks. Awesome community. This worked on Ubuntu 16.04!

Be aware of what you are trying to simlink to

I have libhdf5_serial.so.10 not libhdf5_serial.so.8.0.2

See @jeremy-rutman's comment above.

Caffe compilation is now happily eating up my macbook's cycles.

@GonzaBCCC
Copy link

ln: fallo al crear el enlace simbólico '/usr/lib/x86_64-linux-gnu/libhdf5.so': El archivo ya existe

Basically it fails to create the simlink because it states that the file already exists. Still, i keep getting the /usr/bin/ld: cannot find -lhdf5_serial_hl error...

@yehan-xiao
Copy link

https://ahmedibrahimvt.wordpress.com/2017/02/19/fatal-error-hdf5-h-no-such-file-or-directory/
The most perfect answer I have seen

@loretoparisi
Copy link

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
export CPATH="/usr/include/hdf5/serial/"

@hoangcuong2011
Copy link

Thank you @bucketzxm. It works like a charm!

@jacobkimmel
Copy link

Worked on ubuntu 16.04 LTS for me. Thanks!

@TiborUdvari
Copy link

You should use CMAKE and not Make if you are compiling with the solution above

@ejklektov
Copy link

worked on ubuntu 16.04 LTS
thank you @bucketzxm

@blajoie
Copy link

blajoie commented Jul 12, 2018

Worked on ubuntu 18.04, thanks

Note - I had to change:

sudo ln -s libhdf5_serial.so.8.0.2 libhdf5.so
sudo ln -s libhdf5_serial_hl.so.8.0.2 libhdf5_hl.so

to

sudo ln -s libhdf5_serial.so.100.0.0 libhdf5.so
sudo ln -s libhdf5_serial.so.100.0.1 libhdf5_hl.so

install opencv:
apt-get install libopencv-dev

And had to remove the following lines from the makefile since I am on cuda 9.0:

-gencode arch=compute_20,code=sm_20
-gencode arch=compute_20,code=sm_21

@Eavis Eavis mentioned this issue Oct 15, 2018
@rsandler00
Copy link

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

Thanks @loretoparisi this worked for me!

@rawells14
Copy link

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
export CPATH="/usr/include/hdf5/serial/"

Thank you! This worked for me

@mrgloom
Copy link

mrgloom commented Nov 20, 2018

This helped me
https://askubuntu.com/a/645089/266204

@Chappie74
Copy link

Tried to do the symbolic link, those didn't work. This worked for me. Thanks. (i still have the symbolic links added too)

@Aqirito
Copy link

Aqirito commented Jan 20, 2020

after do the two steps @tangshi mentioned, I continued to add the following lines in MakeFile.config
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/ and
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/

where to find MakeFile.config?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests