Caffe安装,最后一步runtest找不到文件libhdf5_hl.so

问题:

img

我是根据这个网址的教程来的,https://www.helloworld.net/p/2139420397
但是运行到最后一步runtest的时候出错了

为什么它会找不到libhdf5_h.so这个文件,明明我已经把路径添加到Makefile.config里面了

img


img

如果在安装Caffe时出现runtest找不到libhdf5_hl.so和libhdf5_h.so的错误,可能是由于环境变量未正确设置导致的。你可以尝试以下方法解决问题:

1.确认libhdf5_hl.so和libhdf5_h.so文件是否已经正确安装,如果没有安装,可以使用以下命令进行安装:

sudo apt-get install libhdf5-serial-dev

2.确认libhdf5_hl.so和libhdf5_h.so文件所在的路径是否已经添加到环境变量LD_LIBRARY_PATH中。你可以在~/.bashrc文件中添加以下代码:

export LD_LIBRARY_PATH=/path/to/hdf5/lib/:$LD_LIBRARY_PATH

其中/path/to/hdf5/lib/是libhdf5_hl.so和libhdf5_h.so文件所在的路径。

3.确认Makefile.config文件中是否正确设置了HDF5_INCLUDE_DIRS和HDF5_LIBRARIES变量。你可以打开Makefile.config文件,检查以下两个变量是否已经正确设置:

# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1

# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
MATLAB_DIR := /usr/local
# MATLAB_DIR := /Applications/MATLAB_R2012b.app

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/

# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib

确保INCLUDE_DIRS和LIBRARY_DIRS变量中包含了/usr/include/hdf5/serial/和/usr/lib/x86_64-linux-gnu/hdf5/serial/这两个路径,如果没有包含,可以添加进去。

4.确认环境变量已经生效。你可以打开一个新的终端窗口,输入以下命令:

echo $LD_LIBRARY_PATH

确认输出的结果中包含了/path/to/hdf5/lib/这个路径。

如果你仍然无法解决问题,可以尝试重新编译Caffe,并在编译过程中查看输出,

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^