【问题标题】:Caffe install error on Ubuntu 16.04 for CUDA 8.0 & cuDNN 5.1CUDA 8.0 和 cuDNN 5.1 在 Ubuntu 16.04 上的 Caffe 安装错误
【发布时间】:2016-10-17 02:52:04
【问题描述】:

我正在使用支持 GTX 1080 的 UBUNUTU 16.04 Xenial PC 进行深度学习。但是,我在从 BLVC 或 NVIDIA 源代码编译 caffe 时遇到小问题。安装所有依赖项并链接全局变量后,我仍然缺少一些编译 caffe 的内容。我已经构建了 OpenCV 3.1.0 & OpenBLAS 等。现在从 https://github.com/BVLC/caffe 克隆并输入

cd caffe
 mkdir build
cd build 
cmake ..

给我以下错误——

-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Boost version: 1.58.0
-- Found the following Boost libraries:
--   system
--   thread
--   filesystem
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found GFlags: /usr/include  
-- Found gflags  (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libgflags.so)
-- Found Glog: /usr/include  
-- Found glog    (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libglog.so)
-- Found PROTOBUF: /usr/lib/x86_64-linux-gnu/libprotobuf.so  
-- Found PROTOBUF Compiler: /usr/bin/protoc
CMake Error at /usr/local/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
  Could NOT find HDF5 (missing: HDF5_INCLUDE_DIRS)
Call Stack (most recent call first):
  /usr/local/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/cmake-3.2/Modules/FindHDF5.cmake:360 (find_package_handle_standard_args)
  cmake/Dependencies.cmake:27 (find_package)
  CMakeLists.txt:43 (include)


-- Configuring incomplete, errors occurred!
See also "/home/xhuv/testcaffe/caffe/build/CMakeFiles/CMakeOutput.log".
See also "/home/xhuv/testcaffe/caffe/build/CMakeFiles/CMakeError.log".

我正在使用 Python 3.5.2。 :: Anaconda 4.2.0(64 位),Python 2.7 版也已安装。我根据以下内容编辑了Makefile.config

## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!

# cuDNN acceleration switch (uncomment to build with cuDNN).
USE_CUDNN := 1

# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1

# uncomment to disable IO dependencies and corresponding data layers
 USE_OPENCV := 3
# USE_LEVELDB := 0
# USE_LMDB := 0

# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
#   You should not set this flag if you will be reading LMDBs with any
#   possibility of simultaneous read and write
# ALLOW_LMDB_NOLOCK := 1

# To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++

# CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr

# CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 lines for compatibility.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
        -gencode arch=compute_20,code=sm_21 \
        -gencode arch=compute_30,code=sm_30 \
        -gencode arch=compute_35,code=sm_35 \
        -gencode arch=compute_50,code=sm_50 \
        -gencode arch=compute_50,code=compute_50

# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
BLAS_INCLUDE := /usr/local/include
BLAS_LIB := /usr/local/lib

# Homebrew puts openblas in a directory that is not on the standard search path
#BLAS_INCLUDE := $(shell brew --prefix openblas)/include
#BLAS_LIB := $(shell brew --prefix openblas)/lib

# 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

# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 \
        /usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
ANACONDA_HOME := $(HOME)/anaconda2
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
         $(ANACONDA_HOME)/include/python2.7 \
         $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \

# We need to be able to find libpythonX.X.so or .dylib.
#PYTHON_LIB := /usr/lib
PYTHON_LIB := $(ANACONDA_HOME)/lib

# Homebrew installs numpy in a non standard path (keg only)
PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
PYTHON_LIB += $(shell brew --prefix numpy)/lib

# Uncomment to support layers written in Python (will link against Python libs)
#WITH_PYTHON_LAYER := 1

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

# 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

# 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

BUILD_DIR := build
DISTRIBUTE_DIR := distribute

# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1

# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0

# enable pretty build (comment to see full commands)
Q ?= @ 

# shared object suffix name to differentiate branches
LIBRARY_NAME_SUFFIX := -nv

可能的错误是什么?请帮忙!!

【问题讨论】:

  • 找不到 HDF5(缺少:HDF5_INCLUDE_DIRS)请使用 apt-get 命令安装 hdf5-devel
  • 我在本地安装了 hdf5。还是不行。通过 nvidia-docker 运行 DIGITS 会运行 devserver,但 CAFFE for CUDA 8.0 可能存在问题
  • cmake 好像找不到 hdf5。你有安装hdf5开发版吗?这是 cmake 配置问题....
  • 如果您使用的是 CMake 构建,您将不得不处理 CMakeLists.txt 或 cmake/ 中的文件(如 Dependencies.cmake),见下文...

标签: python ubuntu cmake caffe


【解决方案1】:

您首先需要使用此命令sudo apt-get install libhdf5-serial-dev 安装 HD5F,并将您的库目录添加到此+LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/ ,但库将随其版本添加到其扩展名中,因此您需要创建具有正式名称的符号链接 caffe在执行这样的构建时会寻找$ 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。我希望它有所帮助

【讨论】:

    【解决方案2】:

    Caffe 安装对于特定的架构来说可能具有挑战性。 anaconda 的问题在于它没有使用 python 的相同 protobuf 包来支持 Caffe 所需的 google 协议支持。 Anaconda_Caffe 安装参考this repository

    【讨论】:

      【解决方案3】:

      Ubuntu 16.04 上的 HDF5 安装目录似乎与 cmake FindHDF5 模块不兼容。我花了好几个小时来寻找一种“很好地”解决这个问题的方法,但最终只是修补了cmake/Dependencies.cmake 文件以使 caffe 能够正确编译。

      无论如何,这是补丁:ubuntu1604_caffe_hdf5.patch

      如果您正在寻找一种将其包含到构建脚本(如 Dockerfile)中的快速方法,我已经创建了一个 git.io 链接,您可以在基本 caffe 目录中运行以修补 cmake/Dependencies.cmake:

      wget -O- https://git.io/vHcP3 | patch -p0
      

      【讨论】:

        猜你喜欢
        • 2018-08-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-25
        • 2018-04-30
        • 2021-05-05
        相关资源
        最近更新 更多