Caffe: Error loading shared library libhdf5_hl.so.

Created on 21 Nov 2014  路  35Comments  路  Source: BVLC/caffe

Dear,

After sucessfully compile Caffe, I try to test with mnist dataset.
However, when I run the command "./examples/mnist/train_lenet.sh", I get the following error.

./build/tools/caffe: error while loading shared libraries: libhdf5_hl.so.8: cannot open shared object file: No such file or directory

I check my lib "usr/lib/x86_64-linux-gnu" directory, and I just see libhdf5_hl.so.7 file. So, there is a different between .8 and .7

Please help me to correct the above error.

Thank you

Most helpful comment

I had the same problem with Caffe which I solved by adding _ANACONDA/lib_* path to LD_LIBRARY_PATH in ~.bashrc file and it fixed the issue.

export LD_LIBRARY_PATH="/usr/local/cuda/lib64"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/ubuntu/anaconda/lib"

All 35 comments

Hello,

I'm facing the exact same issue. Does anybody know a solution for this?

Thanks,
Nish

Please ask installation questions on the caffe-users mailing list. Thanks!

Check your LD_LIBRARY_PATH and make sure the libhdf5 linked during installation is the same as that in your library path.

I had this same problem. I found that libhdf5-dev created the files

/usr/lib/x86_64-linux-gnu/libhdf5_hl.so.7
/usr/lib/x86_64-linux-gnu/libhdf5.so.7

After copying them to the new names

/usr/lib/x86_64-linux-gnu/libhdf5_hl.so.8
/usr/lib/x86_64-linux-gnu/libhdf5.so.8

make runtest worked fine. I'm a Linux neophyte though so couldn't tell you why it was looking for the .8 files rather than the .7 files (or why my version of libhdf5-dev installed the .7 files rather than the .8 ones)

I have ran into the same error while running 'make runtest'. Renaming the files as suggested by @andyljones worked for me. Thank you.

I met the similar problem with the latest caffe but can not find libhdf5_hl.so.9. I add the path in anaconda where /anaconda/lib/libhdf5_hl.so.9. It works. But I use matlab interface. After I compiled the caffee_.mexa64 and run the demo. An error occurs: caffe_.mexa64': libhdf5_hl.so.9: cannot open shared object file: No such file or directory. It seems there is a library mismatch between matlab and compile. Do you have any idea how to solve that?

I get similar problem

libhdf5_hl.so.9: cannot open shared object file: No such file or directory

and I find I have the follow so file
./libhdf5_hl.so.8.0.1
./libhdf5hl_fortran.so.8.0.1
./libhdf5_hl_cpp.so
./libhdf5_cpp.so
./libhdf5_hl.so
./libhdf5.so
./libhdf5_fortran.so.8.0.1
./gfortran/modules/hdf5.mod
./libhdf5_hl_cpp.so.8
./libhdf5_fortran.so.8
./libhdf5_fortran.so
./libhdf5_hl_cpp.so.8.0.1
./libhdf5hl_fortran.so.8
./libhdf5.settings
./libhdf5.so.8.0.1
./libhdf5hl_fortran.so
./libhdf5.so.8

Hi, I solved this problem yesterday. It seems c++ compiler and matlab will search /usr/lib/x86_64-linux-gnu to find libhdf5_hl.so.9 and libhdf5.so.9. If you use anaconda, there will be these version library. Simiple set a soft link to the above path.
I found another guys just change the name of these two to .9. You can have a try

I just tried with the Anaconda LD_LIBRARY_PATH but then I had other problems with other libraries. And I think that also affects the Matlab interface, as it is not using the global .so file but the Anaconda's one.

You may try these instructions, they worked for me (but I'm not sure if they would fix the Matlab issue):

  • Go to the libraries directory:

cd /usr/lib/x86_64-linux-gnu

  • Link the system version of HDF5 from 7 to 9:

sudo ln -s libhdf5.so.7 libhdf5.so.9 sudo ln -s libhdf5_hl.so.7 libhdf5_hl.so.9

  • Update the "Dynamic Linker":

sudo ldconfig

I wrote a full guide for Ubuntu 14.04 that is pending in the pull request #2129, but you can try it, I just used it (and updated it for the current Caffe code) and it worked: https://github.com/tiangolo/caffe/blob/ubuntu-tutorial-b/docs/install_apt2.md

My problem is that there is no libhdf5.so.X file at all in the path. There is however, a /hdf5/serial/libhdf5.so file, and a few libhdf5_cpp.so.X and libhdf5_serial files.

Anybody help please?

the same problems, although the ibhdf5.so.10 can be found in anaconda/lib, it still doesn't work. However, I solved it with @tiangolo 's instructions, thanks

I had the same problem with Caffe which I solved by adding _ANACONDA/lib_* path to LD_LIBRARY_PATH in ~.bashrc file and it fixed the issue.

export LD_LIBRARY_PATH="/usr/local/cuda/lib64"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/ubuntu/anaconda/lib"

Working on Centos7, adding the Anaconda lib to LD_LIBRARY_PATH as suggested by andrusiak has worked for me.

Working on Ubuntu 14.04 using @andrusiak's solution. I just added
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/ubuntu/anaconda/lib" >> ~/.bashrc to my install script after installing Anaconda. Thanks!

I confirmed that the following is working, while I am considering to add library path suggested @byandrusiak which seems more systematic to me.
~/anaconda/pkgs/hdf5-1.8.15.1-1/lib$ sudo cp libhdf5.so.10.0.1 /usr/lib/x86_64-linux-gnu/
~/anaconda/pkgs/hdf5-1.8.15.1-1/lib$ sudo cp libhdf5_hl.so.10.0.1 /usr/lib/x86_64-linux-gnu/
(I try copying like that. Is it okay to solve the problem after I make symbolic links of them? --> Confirmed by myself.)

So, I contributed this fact to the installation guide for Ubuntu.
https://github.com/tiangolo/caffe/blob/e12f3e4c565f68111bdbab396f7b256ac57de4f5/docs/install_apt2.md

@jskDr thanks for the contribution! I tried that, but it resulted in some other errors afterwards as pointed out in this comment above: https://github.com/BVLC/caffe/issues/1463#issuecomment-130902315 by @guangyu-ryan.

Although right now I don't remember which errors exactly.

Work too, thanks

@andrusiak Thank you. The problem has been fixed according to your advice

LD_LIBRARY_PATH=/usr/local/lib && export LD_LIBRARY_PATH && make runtest
work for me

I think you need to remake your caffe.

I have the same problem. But I didn't find any libhdf5 file in the /usr/lib/x86_64-linux-gnu/, so I just copy it from anaconda, then it is solved.

LD_LIBRARY_PATH=/home/my_user_name/anaconda2/lib && export LD_LIBRARY_PATH && make runtest

worked for me.

do like @link9 or do as follows:
(1) add 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/lib:/usr/local/hdf5/lib' to the end of file ~/.bashrc
(2) source ~/.bashrc

then run make runtest OK

sudo cp ~/anaconda/lib/libhdf5* /usr/lib/x86_64-linux-gnu/ works for me.

In Ubuntu15.10 with anaconda2, @andrusiak 's instruction works for me. Thanks

If you use conda, the file is in the folder "anaconda/lib". So I used the "LD_LIBRARY_PATH="path to anaconda lib" && export LD_LIBRARY_PATH && make runtest. It works!

the version of libhdf5_hl.so is decided by what?
I have libhdf5_hl.so.8 in my system, the link is right, but it trys to find .so.9.
Why this will happen, someone can explain that?

My solution : remove anaconda from the path and rebuild.

In Ubuntu with Anaconda Python installed, you could change the hdf5 libs to take from what is installed by package manager. Snapshot attached below
CMakeCache.txt

image

find your library file
find / -name libhdf5.so\* 2>/dev/null
You can see the path. Append that path like this,
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/where/you/see/the/lib
Append only the folder path, not including .so file itself.
Then run make runtest

I have already installed cuda-8.0
I am facing this problem when I run 'make all' command during compilation of caffe.
please help me to solve this issue?

In file included from src/caffe/solver.cpp:8:0:
./include/caffe/util/hdf5.hpp:6:18: fatal error: hdf5.h: No such file or directory
compilation terminated.
Makefile:581: recipe for target '.build_release/src/caffe/solver.o' failed
make: * [.build_release/src/caffe/solver.o] Error 1

sudo cp ~/anaconda/lib/libhdf5* /usr/lib/x86_64-linux-gnu/ works for me.
@yihui-he helped me.

I had this same problem. I found that libhdf5-dev created the files

/usr/lib/x86_64-linux-gnu/libhdf5_hl.so.7
/usr/lib/x86_64-linux-gnu/libhdf5.so.7

After copying them to the new names

/usr/lib/x86_64-linux-gnu/libhdf5_hl.so.8
/usr/lib/x86_64-linux-gnu/libhdf5.so.8

make runtest worked fine. I'm a Linux neophyte though so couldn't tell you why it was looking for the .8 files rather than the .7 files (or why my version of libhdf5-dev installed the .7 files rather than the .8 ones)

for me installing libhdf5-dev did the trick

sudo cp ~/anaconda/lib/libhdf5* /usr/lib/x86_64-linux-gnu/ works for me.

thank u锛乮鈥榲e been troubled in this problem for 2 full days! it really works for me !

When trying to compile ensmallen I get issue that lib/x86_64-linux-gnu/libarmadillo.so needs libhdf5.so.103. This file is in my anaconda library and I can compile armadillo programs after setting LD_LIBRARY_PATH=/home/user/anaconda3/lib but cannot install ensmallen as tests fail. The only file in lib/x86_64-linux-gnu is libhdf5_serial.so.103. There is no libhdf5.so.103

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dfotland picture dfotland  路  3Comments

vladislavdonchev picture vladislavdonchev  路  3Comments

OpenHero picture OpenHero  路  3Comments

iamhankai picture iamhankai  路  3Comments

weather319 picture weather319  路  3Comments