yun-liu / RCF

Richer Convolutional Features for Edge Detection
Other
752 stars 259 forks source link

Build problem: Undefined reference to gflags. #81

Closed nemkin closed 5 years ago

nemkin commented 5 years ago

Hello,

I have been trying to build RCF for several days and I have given up. Could you please help me figure out how to solve this problem?

Details:

GPU: NVIDIA GeForce GTX 1060 6GB OS: Ubuntu 18.04.01 LTS Cuda: 9.1 cuDNN: 5.1.10

Installed dependencies like this (this might be more than needed, but I have tried multiple different ways to install and failed miserably):

sudo apt install gcc-5 g++-5 libboost-all-dev libgoogle-glog-dev \
libgflags-dev libhdf5-dev python-numpy libatlas-base-dev \
liblapack-dev libblas-dev libopencv-dev liblmdb-dev libleveldb-dev \
libsnappy-dev libcaffe-cuda-dev caffe-cuda

Since the apt caffe package uses protobuf 2.6.1 and RCF told me it needs to be compiled with the same protobuf version as caffe I manually installed that protobuf version from source.

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++-5

# 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_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
#              -gencode arch=compute_20,code=sm_20 \
#              -gencode arch=compute_20,code=sm_21 \

# 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)/anaconda
# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
        # $(ANACONDA_HOME)/include/python2.7 \
        # $(ANACONDA_HOME)/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 := $(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 /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial

# 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 ?= @

Build output:

$ cmake .
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   system
--   thread
--   filesystem
--   chrono
--   date_time
--   atomic
-- Found gflags  (include: /usr/local/include, library: /usr/local/lib/libgflags.a)
-- Found glog    (include: /usr/local/include, library: /usr/local/lib/libglog.a)
-- Found PROTOBUF Compiler: /usr/bin/protoc
-- HDF5: Using hdf5 compiler wrapper to determine C configuration
-- HDF5: Using hdf5 compiler wrapper to determine CXX configuration
-- Found lmdb    (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/liblmdb.so)
-- Found LevelDB (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libleveldb.so)
-- Found Snappy  (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libsnappy.so)
-- CUDA detected: 9.1
-- Found cuDNN: ver. 5.1.10 found (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libcudnn.so)
-- Automatic GPU detection failed. Building for all known architectures.
-- Added CUDA NVCC flags for: sm_30 sm_35 sm_50
-- OpenCV found (/usr/share/OpenCV)
-- Found Atlas (include: /usr/include/x86_64-linux-gnu, library: /usr/lib/x86_64-linux-gnu/libatlas.so)
-- NumPy ver. 1.13.3 found (include: /usr/lib/python2.7/dist-packages/numpy/core/include)
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   python
-- Can't find OUTPUT_DIRECTORY in doxygen config file. Try to use default: ./doxygen/
-- 
-- ******************* Caffe Configuration Summary *******************
-- General:
--   Version           :   1.0.0-rc3
--   Git               :   cd007ac-dirty
--   System            :   Linux
--   C++ compiler      :   /usr/bin/g++-5
--   Release CXX flags :   -O3 -DNDEBUG -std=c++11 -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
--   Debug CXX flags   :   -g -std=c++11 -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
--   Build type        :   Release
-- 
--   BUILD_SHARED_LIBS :   ON
--   BUILD_python      :   ON
--   BUILD_matlab      :   OFF
--   BUILD_docs        :   ON
--   CPU_ONLY          :   OFF
--   USE_OPENCV        :   ON
--   USE_LEVELDB       :   ON
--   USE_LMDB          :   ON
--   ALLOW_LMDB_NOLOCK :   OFF
-- 
-- Dependencies:
--   BLAS              :   Yes (Atlas)
--   Boost             :   Yes (ver. 1.65)
--   glog              :   Yes
--   gflags            :   Yes
--   protobuf          :   Yes (ver. 2.6.1)
--   lmdb              :   Yes (ver. 0.9.21)
--   LevelDB           :   Yes (ver. 1.20)
--   Snappy            :   Yes (ver. ..)
--   OpenCV            :   Yes (ver. 3.2.0)
--   CUDA              :   Yes (ver. 9.1)
-- 
-- NVIDIA CUDA:
--   Target GPU(s)     :   Auto
--   GPU arch(s)       :   sm_30 sm_35 sm_50
--   cuDNN             :   Yes (ver. 5.1.10)
-- 
-- Python:
--   Interpreter       :   /usr/bin/python2.7 (ver. 2.7.15)
--   Libraries         :   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.15rc1)
--   NumPy             :   /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.3)
-- 
-- Documentaion:
--   Doxygen           :   /usr/bin/doxygen (1.8.13)
--   config_file       :   /home/nemkin/Downloads/rcf/.Doxyfile
-- 
-- Install:
--   Install path      :   /home/nemkin/Downloads/rcf/install
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/nemkin/Downloads/rcf
$ make
[  2%] Built target proto
[ 87%] Built target caffe
[ 88%] Linking CXX executable extract_features
../lib/libcaffe.so.1.0.0-rc3: undefined reference to `gflags::FlagRegisterer::FlagRegisterer<int>(char const*, char const*, char const*, int*, int*)'
../lib/libcaffe.so.1.0.0-rc3: undefined reference to `gflags::FlagRegisterer::FlagRegisterer<bool>(char const*, char const*, char const*, bool*, bool*)'
../lib/libcaffe.so.1.0.0-rc3: undefined reference to `gflags::FlagRegisterer::FlagRegisterer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(char const*, char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
collect2: error: ld returned 1 exit status
tools/CMakeFiles/extract_features.dir/build.make:137: recipe for target 'tools/extract_features' failed
make[2]: *** [tools/extract_features] Error 1
CMakeFiles/Makefile2:435: recipe for target 'tools/CMakeFiles/extract_features.dir/all' failed
make[1]: *** [tools/CMakeFiles/extract_features.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

I don't understand how cmake can find gflags, according to this line:

-- Found gflags  (include: /usr/local/include, library: /usr/local/lib/libgflags.a)

But then when I run make, it can't find it:

../lib/libcaffe.so.1.0.0-rc3: undefined reference to `gflags::FlagRegisterer::FlagRegisterer<int>(char const*, char const*, char const*, int*, int*)'
yun-liu commented 5 years ago

When we build Caffe, we need not to run cmake command, and most of the attempts on this may be failed. To build Caffe, you can download this repo, and make sure the Makefile.config is right. Then, you can directly run make command to build Caffe. You can try this, and tell me the info you get.

nemkin commented 5 years ago

Thank you for the answer!

I have cloned the rcf repository fresh, copied the Makefile.config (which I posted in my initial comment here) into it and ran make (no cmake). It had the same results as before:

nemkin@nemkin:~/Downloads/rcf2$ make
PROTOC src/caffe/proto/caffe.proto
CXX .build_release/src/caffe/proto/caffe.pb.cc
CXX src/caffe/solver.cpp
CXX src/caffe/layer.cpp
CXX src/caffe/blob.cpp
CXX src/caffe/data_reader.cpp
CXX src/caffe/syncedmem.cpp
CXX src/caffe/layers/log_layer.cpp
CXX src/caffe/layers/tile_layer.cpp
CXX src/caffe/layers/rnn_layer.cpp
CXX src/caffe/layers/im2col_layer.cpp
CXX src/caffe/layers/cudnn_sigmoid_layer.cpp
CXX src/caffe/layers/input_layer.cpp
CXX src/caffe/layers/recurrent_layer.cpp
CXX src/caffe/layers/argmax_layer.cpp
CXX src/caffe/layers/lstm_layer.cpp
CXX src/caffe/layers/power_layer.cpp
CXX src/caffe/layers/batch_reindex_layer.cpp
CXX src/caffe/layers/concat_layer.cpp
CXX src/caffe/layers/hdf5_output_layer.cpp
CXX src/caffe/layers/relu_layer.cpp
CXX src/caffe/layers/cudnn_pooling_layer.cpp
CXX src/caffe/layers/base_conv_layer.cpp
CXX src/caffe/layers/lrn_layer.cpp
CXX src/caffe/layers/multinomial_logistic_loss_layer.cpp
CXX src/caffe/layers/flatten_layer.cpp
CXX src/caffe/layers/silence_layer.cpp
CXX src/caffe/layers/parameter_layer.cpp
CXX src/caffe/layers/cudnn_lcn_layer.cpp
CXX src/caffe/layers/base_data_layer.cpp
CXX src/caffe/layers/image_data_layer.cpp
CXX src/caffe/layers/softmax_layer.cpp
CXX src/caffe/layers/crop_layer.cpp
CXX src/caffe/layers/neuron_layer.cpp
CXX src/caffe/layers/softmax_loss_layer.cpp
CXX src/caffe/layers/embed_layer.cpp
CXX src/caffe/layers/cudnn_lrn_layer.cpp
CXX src/caffe/layers/dropout_layer.cpp
CXX src/caffe/layers/cudnn_relu_layer.cpp
CXX src/caffe/layers/split_layer.cpp
CXX src/caffe/layers/cudnn_conv_layer.cpp
CXX src/caffe/layers/batch_norm_layer.cpp
CXX src/caffe/layers/bias_layer.cpp
CXX src/caffe/layers/spp_layer.cpp
CXX src/caffe/layers/cudnn_tanh_layer.cpp
CXX src/caffe/layers/slice_layer.cpp
CXX src/caffe/layers/accuracy_layer.cpp
CXX src/caffe/layers/contrastive_loss_layer.cpp
CXX src/caffe/layers/reduction_layer.cpp
CXX src/caffe/layers/deconv_layer.cpp
CXX src/caffe/layers/hinge_loss_layer.cpp
CXX src/caffe/layers/sigmoid_cross_entropy_loss_layer.cpp
CXX src/caffe/layers/prelu_layer.cpp
CXX src/caffe/layers/image_labelmap_data_layer.cpp
CXX src/caffe/layers/data_layer.cpp
CXX src/caffe/layers/hdf5_data_layer.cpp
CXX src/caffe/layers/inner_product_layer.cpp
CXX src/caffe/layers/filter_layer.cpp
CXX src/caffe/layers/auto_crop_layer.cpp
CXX src/caffe/layers/infogain_loss_layer.cpp
CXX src/caffe/layers/reshape_layer.cpp
CXX src/caffe/layers/eltwise_layer.cpp
CXX src/caffe/layers/absval_layer.cpp
CXX src/caffe/layers/loss_layer.cpp
CXX src/caffe/layers/lstm_unit_layer.cpp
CXX src/caffe/layers/conv_layer.cpp
CXX src/caffe/layers/memory_data_layer.cpp
CXX src/caffe/layers/euclidean_loss_layer.cpp
CXX src/caffe/layers/tanh_layer.cpp
CXX src/caffe/layers/scale_layer.cpp
CXX src/caffe/layers/dummy_data_layer.cpp
CXX src/caffe/layers/pooling_layer.cpp
CXX src/caffe/layers/sigmoid_layer.cpp
CXX src/caffe/layers/mvn_layer.cpp
CXX src/caffe/layers/exp_layer.cpp
CXX src/caffe/layers/threshold_layer.cpp
CXX src/caffe/layers/window_data_layer.cpp
CXX src/caffe/layers/bnll_layer.cpp
CXX src/caffe/layers/elu_layer.cpp
CXX src/caffe/layers/cudnn_softmax_layer.cpp
CXX src/caffe/solvers/nesterov_solver.cpp
CXX src/caffe/solvers/adam_solver.cpp
CXX src/caffe/solvers/adadelta_solver.cpp
CXX src/caffe/solvers/sgd_solver.cpp
CXX src/caffe/solvers/rmsprop_solver.cpp
CXX src/caffe/solvers/adagrad_solver.cpp
CXX src/caffe/parallel.cpp
CXX src/caffe/layer_factory.cpp
CXX src/caffe/internal_thread.cpp
CXX src/caffe/util/cudnn.cpp
CXX src/caffe/util/io.cpp
CXX src/caffe/util/math_functions.cpp
CXX src/caffe/util/db_lmdb.cpp
CXX src/caffe/util/im2col.cpp
CXX src/caffe/util/upgrade_proto.cpp
CXX src/caffe/util/benchmark.cpp
CXX src/caffe/util/blocking_queue.cpp
CXX src/caffe/util/db_leveldb.cpp
CXX src/caffe/util/hdf5.cpp
CXX src/caffe/util/insert_splits.cpp
CXX src/caffe/util/db.cpp
CXX src/caffe/util/signal_handler.cpp
CXX src/caffe/net.cpp
CXX src/caffe/common.cpp
CXX src/caffe/data_transformer.cpp
NVCC src/caffe/layers/mvn_layer.cu
NVCC src/caffe/layers/bias_layer.cu
NVCC src/caffe/layers/inner_product_layer.cu
NVCC src/caffe/layers/softmax_loss_layer.cu
NVCC src/caffe/layers/cudnn_relu_layer.cu
NVCC src/caffe/layers/batch_norm_layer.cu
NVCC src/caffe/layers/power_layer.cu
NVCC src/caffe/layers/absval_layer.cu
NVCC src/caffe/layers/hdf5_output_layer.cu
NVCC src/caffe/layers/cudnn_lrn_layer.cu
NVCC src/caffe/layers/lstm_unit_layer.cu
NVCC src/caffe/layers/tanh_layer.cu
NVCC src/caffe/layers/concat_layer.cu
NVCC src/caffe/layers/filter_layer.cu
NVCC src/caffe/layers/silence_layer.cu
NVCC src/caffe/layers/prelu_layer.cu
NVCC src/caffe/layers/pooling_layer.cu
NVCC src/caffe/layers/crop_layer.cu
NVCC src/caffe/layers/split_layer.cu
NVCC src/caffe/layers/cudnn_lcn_layer.cu
NVCC src/caffe/layers/recurrent_layer.cu
NVCC src/caffe/layers/cudnn_softmax_layer.cu
NVCC src/caffe/layers/auto_crop_layer.cu
NVCC src/caffe/layers/cudnn_conv_layer.cu
NVCC src/caffe/layers/embed_layer.cu
NVCC src/caffe/layers/reduction_layer.cu
NVCC src/caffe/layers/cudnn_sigmoid_layer.cu
NVCC src/caffe/layers/elu_layer.cu
NVCC src/caffe/layers/relu_layer.cu
NVCC src/caffe/layers/eltwise_layer.cu
NVCC src/caffe/layers/bnll_layer.cu
NVCC src/caffe/layers/batch_reindex_layer.cu
NVCC src/caffe/layers/conv_layer.cu
NVCC src/caffe/layers/contrastive_loss_layer.cu
NVCC src/caffe/layers/scale_layer.cu
NVCC src/caffe/layers/sigmoid_layer.cu
NVCC src/caffe/layers/euclidean_loss_layer.cu
NVCC src/caffe/layers/dropout_layer.cu
NVCC src/caffe/layers/log_layer.cu
NVCC src/caffe/layers/exp_layer.cu
NVCC src/caffe/layers/base_data_layer.cu
NVCC src/caffe/layers/cudnn_tanh_layer.cu
NVCC src/caffe/layers/slice_layer.cu
NVCC src/caffe/layers/hdf5_data_layer.cu
NVCC src/caffe/layers/deconv_layer.cu
NVCC src/caffe/layers/tile_layer.cu
NVCC src/caffe/layers/cudnn_pooling_layer.cu
NVCC src/caffe/layers/lrn_layer.cu
NVCC src/caffe/layers/threshold_layer.cu
NVCC src/caffe/layers/im2col_layer.cu
NVCC src/caffe/layers/softmax_layer.cu
NVCC src/caffe/solvers/adagrad_solver.cu
NVCC src/caffe/solvers/adam_solver.cu
NVCC src/caffe/solvers/sgd_solver.cu
NVCC src/caffe/solvers/rmsprop_solver.cu
NVCC src/caffe/solvers/nesterov_solver.cu
NVCC src/caffe/solvers/adadelta_solver.cu
NVCC src/caffe/util/im2col.cu
NVCC src/caffe/util/math_functions.cu
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0-rc3
CXX tools/caffe.cpp
CXX/LD -o .build_release/tools/caffe.bin
.build_release/lib/libcaffe.so: undefined reference to `gflags::FlagRegisterer::FlagRegisterer<int>(char const*, char const*, char const*, int*, int*)'
.build_release/lib/libcaffe.so: undefined reference to `gflags::FlagRegisterer::FlagRegisterer<bool>(char const*, char const*, char const*, bool*, bool*)'
.build_release/lib/libcaffe.so: undefined reference to `gflags::FlagRegisterer::FlagRegisterer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(char const*, char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
collect2: error: ld returned 1 exit status
Makefile:619: recipe for target '.build_release/tools/caffe.bin' failed
make: *** [.build_release/tools/caffe.bin] Error 1
yun-liu commented 5 years ago

You can try sudo apt-get install libprotobuf-dev protobuf-compiler libgflags-dev libgoogle-glog-dev. If it still doesn't work, maybe you can use our PyTorch implementation of RCF with some performance degradation. The PyTorch repo is here.

yun-liu commented 5 years ago

My operation system is Ubuntu 16.04.

nemkin commented 5 years ago

Hi,

finally, I got it working! Thank you for the answers! :)

Here is what I did, if someone else stumbles upon this issue:

I have started completely anew. Reinstalled Ubuntu 18.04.01 LTS (because my system was just messed up at this point) and installed Cuda 10.1 and libcudnn 7.5.1 from the Nvidia website.

Ran this:

sudo apt-get install libprotobuf-dev protobuf-compiler libgflags-dev libgoogle-glog-dev \
libboost-all-dev libatlas-base-dev libhdf5-dev libopencv-dev libleveldb-dev liblmdb-dev \
libsnappy-dev

Edited the Makefile.config to this:

## 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_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
#       -gencode arch=compute_20,code=sm_20 \
#       -gencode arch=compute_20,code=sm_21 \

# 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)/anaconda
# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
        # $(ANACONDA_HOME)/include/python2.7 \
        # $(ANACONDA_HOME)/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 := $(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 /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial

# 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 ?= @

Edited the Makefile's build flags and added C++11 support:

# Complete build flags.
COMMON_FLAGS += $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) --std=c++11
CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)
NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
# mex may invoke an older gcc that is too liberal with -Wuninitalized
MATLAB_CXXFLAGS := $(CXXFLAGS) -Wno-uninitialized
LINKFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)

And finally, I followed what this comment said and downloaded a newer version of cudnn.hpp for support of newer versions of libcudnn:

https://github.com/BVLC/caffe/issues/5793#issuecomment-404729152

The mistakes I made previously, and why I thought just reinstalling Ubuntu would be easier:

Thank you for your help!

Best regards, Viktória

yun-liu commented 5 years ago

Congratulations!