在 Ubuntu 17.04 (libhdf5.so) 中安装 Caffe 时出错

Error at installing Caffe in Ubuntu 17.04 (libhdf5.so)

在我的 Ubuntu 17.04 上安装(编译)Caffe(第一个版本)时,我收到以下错误:

*** No rule to make target '/usr/lib/x86_64-linux-gnu/"libhdf5.so"', needed by 'lib/libcaffe.so.1.0.0'. Stop.

我的电脑规格如下:

> nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2016 NVIDIA
> Corporation Built on Tue_Jan_10_13:22:03_CST_2017 Cuda compilation
> tools, release 8.0, V8.0.61

使用的gcc:

There are 4 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path              Priority   Status
------------------------------------------------------------
  0            /usr/bin/gcc-4.9   10        auto mode
  1            /usr/bin/g++-4.9   10        manual mode
* 2            /usr/bin/gcc-4.9   10        manual mode
  3            /usr/bin/gcc-5     10        manual mode
  4            /usr/bin/gcc-6     10        manual mode

OpenCV 版本:

$ pkg-config --modversion opencv
3.2.0

CUDNN版本是最新的什么是v6.0

关于 the official website 我已经添加了以下内容:

find . -type f -exec sed -i -e 's^"hdf5.h"^"hdf5/serial/hdf5.h"^g' -e 's^"hdf5_hl.h"^"hdf5/serial/hdf5_hl.h"^g' '{}' \;

cd /usr/lib/x86_64-linux-gnu

sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so

sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so

并将 Makefile.config 修改为:

 USE_CUDNN := 1
 OPENCV_VERSION := 3
 CUDA_DIR := /usr/local/cuda-8.0
 BLAS := atlas
 PYTHON_INCLUDE :=  /usr/include/python2.7 /usr/local/lib/python2.7/dist-packages/numpy/core/include
 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 /usr/lib/x86_64-linux-gnu/hdf5/serial

Makefile为:

NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)

LIBRARIES += glog gflags protobuf leveldb snappy \
  lmdb boost_system boost_filesystem hdf5_hl hdf5 m \
  opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs opencv_videoio

但在 运行 之后仍然出现相同的错误 cmake .. 或 make all -j8make pycaffe -j4:

CMakeFiles/Makefile2:267: recipe for target 'src/caffe/CMakeFiles/caffe.dir/all' failed make2: *** [src/caffe/CMakeFiles/caffe.dir/all] Error 2

CMakeFiles/Makefile2:1129: recipe for target 'python/CMakeFiles/pycaffe.dir/rule' failed make1: *** [python/CMakeFiles/pycaffe.dir/rule] Error 2

Makefile:487: recipe for target 'pycaffe' failed make: *** [pycaffe] Error 2

执行后的相关包列表如下:

$ cd /usr/lib/x86_64-linux-gnu

然后:

$ ls -l | grep hdf5

结果如下:

drwxr-xr-x  3 root root      4096 May 17 06:37 hdf5
-rw-r--r--  1 root root    972640 Dec  5 08:27 libhdf5_cpp.a
lrwxrwxrwx  1 root root        22 Dec  5 08:27 libhdf5_cpp.so -> libhdf5_cpp.so.100.0.0
lrwxrwxrwx  1 root root        22 Dec  5 08:27 libhdf5_cpp.so.100 -> libhdf5_cpp.so.100.0.0
-rw-r--r--  1 root root    414392 Dec  5 08:27 libhdf5_cpp.so.100.0.0
-rw-r--r--  1 root root     13098 Dec  5 08:27 libhdf5_hl_cpp.a
lrwxrwxrwx  1 root root        25 Dec  5 08:27 libhdf5_hl_cpp.so -> libhdf5_hl_cpp.so.100.0.0
lrwxrwxrwx  1 root root        25 Dec  5 08:27 libhdf5_hl_cpp.so.100 -> libhdf5_hl_cpp.so.100.0.0
-rw-r--r--  1 root root     14736 Dec  5 08:27 libhdf5_hl_cpp.so.100.0.0
lrwxrwxrwx  1 root root        27 May 21 16:18 libhdf5_hl.so -> libhdf5_serial_hl.so.10.0.2
-rw-r--r--  1 root root   7841328 Dec  5 08:27 libhdf5_serial.a
-rw-r--r--  1 root root    398780 Dec  5 08:27 libhdf5_serial_fortran.a
lrwxrwxrwx  1 root root        33 Dec  5 08:27 libhdf5_serial_fortran.so -> libhdf5_serial_fortran.so.100.0.1
lrwxrwxrwx  1 root root        33 Dec  5 08:27 libhdf5_serial_fortran.so.100 -> libhdf5_serial_fortran.so.100.0.1
-rw-r--r--  1 root root    254920 Dec  5 08:27 libhdf5_serial_fortran.so.100.0.1
-rw-r--r--  1 root root    245528 Dec  5 08:27 libhdf5_serial_hl.a
-rw-r--r--  1 root root    186570 Dec  5 08:27 libhdf5_serialhl_fortran.a
lrwxrwxrwx  1 root root        35 Dec  5 08:27 libhdf5_serialhl_fortran.so -> libhdf5_serialhl_fortran.so.100.0.0
lrwxrwxrwx  1 root root        35 Dec  5 08:27 libhdf5_serialhl_fortran.so.100 -> libhdf5_serialhl_fortran.so.100.0.0
-rw-r--r--  1 root root    121464 Dec  5 08:27 libhdf5_serialhl_fortran.so.100.0.0
lrwxrwxrwx  1 root root        28 Dec  5 08:27 libhdf5_serial_hl.so -> libhdf5_serial_hl.so.100.0.0
lrwxrwxrwx  1 root root        28 Dec  5 08:27 libhdf5_serial_hl.so.100 -> libhdf5_serial_hl.so.100.0.0
-rw-r--r--  1 root root    142744 Dec  5 08:27 libhdf5_serial_hl.so.100.0.0
-rw-r--r--  1 root root      4084 Dec  5 08:27 libhdf5_serial.settings
lrwxrwxrwx  1 root root        25 Dec  5 08:27 libhdf5_serial.so -> libhdf5_serial.so.100.0.1
lrwxrwxrwx  1 root root        25 Dec  5 08:27 libhdf5_serial.so.100 -> libhdf5_serial.so.100.0.1
-rw-r--r--  1 root root   3491952 Dec  5 08:27 libhdf5_serial.so.100.0.1
lrwxrwxrwx  1 root root        24 May 21 16:16 libhdf5.so -> libhdf5_serial.so.10.1.0

非常感谢您的帮助,因为最近几天我正在努力安装 Caffe。另外,我考虑安装 Caffe2,但我无法安装那个,嗯。

以下两行并不总是必要的,甚至可能会导致问题:

sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so

此外,请确保已安装所有 hdf5 依赖项。

  1. 作为通用构建提示,请确保在 'make pycaffe' 之前 运行 'make all'。

  2. 官网确认目前(2017年5月23日)只在Ubuntu16.04或14.10上安装。

  3. 确保您拥有 CUDNN 5.1 版(不是最新的 6 版),因为它是唯一推荐的版本(2017 年 5 月 23 日)。

使用休闲命令 sudo -H pip3 install --upgrade pipsudo -H pip2 install --upgrade pipsudo -H apt-get install python-tksudo -H apt-get install python3-tksudo -H pip3 install easysetupsudo -H pip2 install easysetup

然后重新开始。