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

时间:2017-05-21 17:01:08

标签: python opencv caffe opencv3.0 ubuntu-17.04

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

  

***没有规则要制作'/usr/lib/x86_64-linux-gnu/"libhdf5.so“'目标,'lib / libcaffe.so.1.0.0'需要。停止。

enter image description here

我的电脑规格如下:

> 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 as:

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:目标的配方   'src / caffe / CMakeFiles / caffe.dir / all'失败make 2:***   [src / caffe / CMakeFiles / caffe.dir / all]错误2

     

CMakeFiles / Makefile2:1129:目标的配方   'python / CMakeFiles / pycaffe.dir / rule'失败了make 1:***   [python / CMakeFiles / pycaffe.dir / rule]错误2

     

Makefile:487:目标'pycaffe'的配方失败make:*** [pycaffe]   错误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,但是我无法安装那个。

3 个答案:

答案 0 :(得分:1)

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

  2. 官方网站在此日(2017年5月23日)仅在Ubuntu 16.04或14.10上确认安装。

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

答案 1 :(得分:0)

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

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个依赖项。

答案 2 :(得分:0)

使用了fallowing命令 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

然后重新开始。