machine-learning - 安装时编译caffe文件(Makefile.config)时出现错误

标签 machine-learning compilation computer-vision installation

有人可以在安装过程中编译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 ?= @

然后是相应的编译结果(或错误) (提示:Error表示错误或错误)

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

最佳答案

  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

关于machine-learning - 安装时编译caffe文件(Makefile.config)时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37746917/

相关文章:

machine-learning - 用于不平衡多类多标签分类的神经网络

compilation - 使用 grunt-contrib-stylus 进行编译时,手写笔出现 "EOS"错误

c++ - 局部变量在编译时存储在哪里?

从 C 代码编译汇编代码而不使用 gcc 中的特定寄存器

python - 在图像锐化中进行相同操作后得到不同的图像阵列

python - 在 Tensorflow2 中将图卡住为 pb

python - MNIST图像预测模型

c++ - OpenCV - SURF 特征比较

python - 寻找一种预处理字符串特征的方法

python - 确保ROI裁剪坐标(x,y,w,h)有效且在Python OpenCV的范围内