在其安装中编译caffe文件时发生错误(Makefile.config)

时间:2016-06-10 11:18:24

标签: machine-learning compilation computer-vision install

在安装过程中编译 caffe 时,某人可以帮助我解决这些错误吗?

这是由我修改的caffe文件的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 := 0
# 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

# Uncomment if you're using OpenCV 3
# OPENCV_VERSION := 3

# 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 := ATLAS
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
# BLAS_INCLUDE := /path/to/your/blas
# BLAS_LIB := /path/to/your/blas

# 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) /home/desmond/anaconda2
PYTHON_INCLUDE := $(ANACONDA_HOME) /home/desmond/anaconda2/include \
        $(ANACONDA_HOME) /home/desmond/anaconda2/include/python2.7 \
        $(ANACONDA_HOME) /home/desmond/anaconda2/lib/python2.7/site-packages/numpy/core/include \

# Uncomment to use Python 3 (default is Python 2)
# PYTHON_LIBRARIES := boost_python3 python3.5m
# PYTHON_INCLUDE := /usr/include/python3.5m \
#                 /usr/lib/python3.5/dist-packages/numpy/core/include

# We need to be able to find libpythonX.X.so or .dylib.
#PYTHON_LIB := /usr/lib
PYTHON_LIB := $/home/desmond/anaconda2/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

# 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

# N.B. both build and distribute dirs are cleared on `make clean`
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 ?= @

然后是相应的编译结果(或错误) (提示:错误意味着错误或错误)

desmond@desmond-Lenovo-IdeaPad-Y400:~/caffe-master$ make all -j4
CXX src/caffe/util/db_leveldb.cpp
CXX src/caffe/parallel.cpp
CXX src/caffe/util/db_lmdb.cpp
CXX src/caffe/util/upgrade_proto.cpp
In file included from ./include/caffe/util/device_alternate.hpp:40:0,
                 from ./include/caffe/common.hpp:19,
                 from ./include/caffe/util/db.hpp:6,
                 from ./include/caffe/util/db_leveldb.hpp:10,
                 from src/caffe/util/db_leveldb.cpp:2:
./include/caffe/util/cudnn.hpp: In function ‘void caffe::cudnn::createPoolingDesc(cudnnPoolingStruct**, caffe::PoolingParameter_PoolMethod, cudnnPoolingMode_t*, int, int, int, int, int, int)’:
./include/caffe/util/cudnn.hpp:136:9: error: ‘CUDNN_PROPAGATE_NAN’ was not declared in this scope
         CUDNN_PROPAGATE_NAN, h, w, pad_h, pad_w, stride_h, stride_w));
         ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                        ^
./include/caffe/util/cudnn.hpp:136:68: error: there are no arguments to ‘cudnnSetPooling2dDescriptor_v4’ that depend on a template parameter, so a declaration of ‘cudnnSetPooling2dDescriptor_v4’ must be available [-fpermissive]
         CUDNN_PROPAGATE_NAN, h, w, pad_h, pad_w, stride_h, stride_w));
                                                                ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                        ^
./include/caffe/util/cudnn.hpp:136:68: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
         CUDNN_PROPAGATE_NAN, h, w, pad_h, pad_w, stride_h, stride_w));
                                                                ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                        ^
./include/caffe/util/cudnn.hpp: At global scope:
./include/caffe/util/cudnn.hpp:141:40: error: variable or field ‘createActivationDescriptor’ declared void
 inline void createActivationDescriptor(cudnnActivationDescriptor_t* activ_desc,
                                    ^
./include/caffe/util/cudnn.hpp:141:40: error: ‘cudnnActivationDescriptor_t’ was not declared in this scope
./include/caffe/util/cudnn.hpp:141:69: error: ‘activ_desc’ was not declared in this scope
 inline void createActivationDescriptor(cudnnActivationDescriptor_t* activ_desc,
                                                                 ^
./include/caffe/util/cudnn.hpp:142:27: error: expected primary-expression before ‘mode’
     cudnnActivationMode_t mode) {
                       ^
In file included from ./include/caffe/util/device_alternate.hpp:40:0,
                 from ./include/caffe/common.hpp:19,
                 from ./include/caffe/util/db.hpp:6,
                 from ./include/caffe/util/db_lmdb.hpp:10,
                 from src/caffe/util/db_lmdb.cpp:2:
./include/caffe/util/cudnn.hpp: In function ‘void caffe::cudnn::createPoolingDesc(cudnnPoolingStruct**, caffe::PoolingParameter_PoolMethod, cudnnPoolingMode_t*, int, int, int, int, int, int)’:
./include/caffe/util/cudnn.hpp:136:9: error: ‘CUDNN_PROPAGATE_NAN’ was not declared in this scope
         CUDNN_PROPAGATE_NAN, h, w, pad_h, pad_w, stride_h, stride_w));
         ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                        ^
./include/caffe/util/cudnn.hpp:136:68: error: there are no arguments to ‘cudnnSetPooling2dDescriptor_v4’ that depend on a template parameter, so a declaration of ‘cudnnSetPooling2dDescriptor_v4’ must be available [-fpermissive]
         CUDNN_PROPAGATE_NAN, h, w, pad_h, pad_w, stride_h, stride_w));
                                                                ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                        ^
./include/caffe/util/cudnn.hpp:136:68: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
         CUDNN_PROPAGATE_NAN, h, w, pad_h, pad_w, stride_h, stride_w));
                                                                ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                        ^
./include/caffe/util/cudnn.hpp: At global scope:
./include/caffe/util/cudnn.hpp:141:40: error: variable or field ‘createActivationDescriptor’ declared void
 inline void createActivationDescriptor(cudnnActivationDescriptor_t* activ_desc,
                                    ^
./include/caffe/util/cudnn.hpp:141:40: error: ‘cudnnActivationDescriptor_t’ was not declared in this scope
./include/caffe/util/cudnn.hpp:141:69: error: ‘activ_desc’ was not declared in this scope
 inline void createActivationDescriptor(cudnnActivationDescriptor_t* activ_desc,
                                                                 ^
./include/caffe/util/cudnn.hpp:142:27: error: expected primary-expression before ‘mode’
     cudnnActivationMode_t mode) {
                       ^
make: *** [.build_debug/src/caffe/util/db_leveldb.o] 错误 1
make: *** 正在等待未完成的任务....
make: *** [.build_debug/src/caffe/util/db_lmdb.o] 错误 1
In file included from ./include/caffe/util/device_alternate.hpp:40:0,
                 from ./include/caffe/common.hpp:19,
                 from src/caffe/util/upgrade_proto.cpp:8:
./include/caffe/util/cudnn.hpp: In function ‘void caffe::cudnn::createPoolingDesc(cudnnPoolingStruct**, caffe::PoolingParameter_PoolMethod, cudnnPoolingMode_t*, int, int, int, int, int, int)’:
./include/caffe/util/cudnn.hpp:136:9: error: ‘CUDNN_PROPAGATE_NAN’ was not declared in this scope
         CUDNN_PROPAGATE_NAN, h, w, pad_h, pad_w, stride_h, stride_w));
         ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                        ^
./include/caffe/util/cudnn.hpp:136:68: error: there are no arguments to ‘cudnnSetPooling2dDescriptor_v4’ that depend on a template parameter, so a declaration of ‘cudnnSetPooling2dDescriptor_v4’ must be available [-fpermissive]
         CUDNN_PROPAGATE_NAN, h, w, pad_h, pad_w, stride_h, stride_w));
                                                                ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                        ^
./include/caffe/util/cudnn.hpp:136:68: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
         CUDNN_PROPAGATE_NAN, h, w, pad_h, pad_w, stride_h, stride_w));
                                                                 ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                        ^
./include/caffe/util/cudnn.hpp: At global scope:
./include/caffe/util/cudnn.hpp:141:40: error: variable or field ‘createActivationDescriptor’ declared void
 inline void createActivationDescriptor(cudnnActivationDescriptor_t* activ_desc,
                                    ^
./include/caffe/util/cudnn.hpp:141:40: error: ‘cudnnActivationDescriptor_t’ was not declared in this scope
./include/caffe/util/cudnn.hpp:141:69: error: ‘activ_desc’ was not declared in this scope
 inline void createActivationDescriptor(cudnnActivationDescriptor_t* activ_desc,
                                                                 ^
./include/caffe/util/cudnn.hpp:142:27: error: expected primary-expression before ‘mode’
     cudnnActivationMode_t mode) {
                       ^
make: *** [.build_debug/src/caffe/util/upgrade_proto.o] 错误 1
In file included from ./include/caffe/util/device_alternate.hpp:40:0,
                 from ./include/caffe/common.hpp:19,
                 from ./include/caffe/blob.hpp:8,
                 from ./include/caffe/caffe.hpp:7,
                 from src/caffe/parallel.cpp:12:
./include/caffe/util/cudnn.hpp: In function ‘void caffe::cudnn::createPoolingDesc(cudnnPoolingStruct**, caffe::PoolingParameter_PoolMethod, cudnnPoolingMode_t*, int, int, int, int, int, int)’:
./include/caffe/util/cudnn.hpp:136:9: error: ‘CUDNN_PROPAGATE_NAN’ was not declared in this scope
         CUDNN_PROPAGATE_NAN, h, w, pad_h, pad_w, stride_h, stride_w));
         ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                        ^
./include/caffe/util/cudnn.hpp:136:68: error: there are no arguments to ‘cudnnSetPooling2dDescriptor_v4’ that depend on a template parameter, so a declaration of ‘cudnnSetPooling2dDescriptor_v4’ must be available [-fpermissive]
         CUDNN_PROPAGATE_NAN, h, w, pad_h, pad_w, stride_h, stride_w));
                                                                ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                        ^
./include/caffe/util/cudnn.hpp:136:68: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
         CUDNN_PROPAGATE_NAN, h, w, pad_h, pad_w, stride_h, stride_w));
                                                                ^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                        ^
./include/caffe/util/cudnn.hpp: At global scope:
./include/caffe/util/cudnn.hpp:141:40: error: variable or field ‘createActivationDescriptor’ declared void
 inline void createActivationDescriptor(cudnnActivationDescriptor_t* activ_desc,
                                    ^
./include/caffe/util/cudnn.hpp:141:40: error: ‘cudnnActivationDescriptor_t’ was not declared in this scope
./include/caffe/util/cudnn.hpp:141:69: error: ‘activ_desc’ was not declared in this scope
 inline void createActivationDescriptor(cudnnActivationDescriptor_t* activ_desc,
                                                                 ^
./include/caffe/util/cudnn.hpp:142:27: error: expected primary-expression before ‘mode’
     cudnnActivationMode_t mode) {
                       ^
make: *** [.build_debug/src/caffe/parallel.o] 错误 1

2 个答案:

答案 0 :(得分:1)

你需要升级cudnn。如果您使用cuda7,请从nvidia获取与cuda7配合使用的最新cudnn(将有一个链接显示“下载cuDNN v4(2016年2月10日),适用于CUDA 7.0及更高版本。”)。安装很简单,只需解压缩并将include和lib64内容复制到cuda文件夹。为了以防万一,我备份了我的cudnn.h和libs,但一切顺利。

tar -zxf cudnn-7.0-linux-x64-v4.0-prod.tgz
cd cuda
sudo cp ./lib64/* /usr/local/cuda/lib64/
sudo cp ./include/cudnn.h /usr/local/cuda/include/

假设您的cuda文件夹是/ usr / local / cuda /

答案 1 :(得分:1)

  1. CUDAcudnn下载到您的计算机。对我来说,我使用的cuda 7.5和cudnn 5.0与最新的Caffe一起工作得很好。
  2. 将cuda和cudnn提取到计算机中的某些位置,分别说</path/to/cuda></path/to/cudnn>
  3. 在您的终端中:

    sudo cp </path/to/cudnn>/lib64/libcudnn* </path/to/cuda>/lib64

    sudo cp </path/to/cudnn>/include/cudnn.h </path/to/cuda>/include

    export PATH=</path/to/cuda>/bin:$PATH

    export LD_LIBRARY_PATH=</path/to/cuda>/lib64</path/to/cudnn>:$LD_LIBRARY_PATH

    source ~/.bashrc

  4. Makefile.config中,更改此行

    # CUDA directory contains bin/ and lib/ directories that we need. CUDA_DIR := /usr/local/cuda

    CUDA_DIR := </path/to/cuda>

  5. make all -j8 && make pycaffe -j8 && make run -j8 && make runtest -j8