caffe build problem

Created on 14 Feb 2016  ·  36Comments  ·  Source: BVLC/caffe

I am receiving the following errors help me please

root@Adarsh:/home/user/caffe# make -k 4 all
make: ** No rule to make target '4'.
PROTOC src/caffe/proto/caffe.proto
CXX .build_release/src/caffe/proto/caffe.pb.cc
CXX src/caffe/util/db_lmdb.cpp
CXX src/caffe/util/blocking_queue.cpp
CXX src/caffe/util/benchmark.cpp
CXX src/caffe/util/insert_splits.cpp
CXX src/caffe/util/hdf5.cpp
CXX src/caffe/util/math_functions.cpp
CXX src/caffe/util/upgrade_proto.cpp
CXX src/caffe/util/im2col.cpp
CXX src/caffe/util/cudnn.cpp
CXX src/caffe/util/db.cpp
CXX src/caffe/util/db_leveldb.cpp
CXX src/caffe/util/signal_handler.cpp
CXX src/caffe/util/io.cpp
CXX src/caffe/parallel.cpp
CXX src/caffe/layer.cpp
CXX src/caffe/data_transformer.cpp
CXX src/caffe/syncedmem.cpp
CXX src/caffe/common.cpp
CXX src/caffe/layer_factory.cpp
CXX src/caffe/data_reader.cpp
CXX src/caffe/internal_thread.cpp
CXX src/caffe/net.cpp
CXX src/caffe/blob.cpp
CXX src/caffe/layers/contrastive_loss_layer.cpp
CXX src/caffe/layers/tile_layer.cpp
CXX src/caffe/layers/cudnn_lrn_layer.cpp
CXX src/caffe/layers/scale_layer.cpp
CXX src/caffe/layers/cudnn_sigmoid_layer.cpp
CXX src/caffe/layers/lrn_layer.cpp
CXX src/caffe/layers/softmax_loss_layer.cpp
CXX src/caffe/layers/slice_layer.cpp
CXX src/caffe/layers/data_layer.cpp
CXX src/caffe/layers/eltwise_layer.cpp
CXX src/caffe/layers/euclidean_loss_layer.cpp
CXX src/caffe/layers/im2col_layer.cpp
CXX src/caffe/layers/threshold_layer.cpp
CXX src/caffe/layers/cudnn_softmax_layer.cpp
CXX src/caffe/layers/memory_data_layer.cpp
CXX src/caffe/layers/softmax_layer.cpp
CXX src/caffe/layers/bias_layer.cpp
CXX src/caffe/layers/flatten_layer.cpp
CXX src/caffe/layers/cudnn_relu_layer.cpp
CXX src/caffe/layers/tanh_layer.cpp
CXX src/caffe/layers/infogain_loss_layer.cpp
CXX src/caffe/layers/sigmoid_layer.cpp
CXX src/caffe/layers/cudnn_pooling_layer.cpp
CXX src/caffe/layers/image_data_layer.cpp
CXX src/caffe/layers/neuron_layer.cpp
CXX src/caffe/layers/filter_layer.cpp
CXX src/caffe/layers/cudnn_conv_layer.cpp
CXX src/caffe/layers/base_data_layer.cpp
CXX src/caffe/layers/spp_layer.cpp
CXX src/caffe/layers/silence_layer.cpp
CXX src/caffe/layers/deconv_layer.cpp
CXX src/caffe/layers/hdf5_output_layer.cpp
CXX src/caffe/layers/window_data_layer.cpp
CXX src/caffe/layers/elu_layer.cpp
CXX src/caffe/layers/pooling_layer.cpp
CXX src/caffe/layers/sigmoid_cross_entropy_loss_layer.cpp
CXX src/caffe/layers/dropout_layer.cpp
CXX src/caffe/layers/reshape_layer.cpp
CXX src/caffe/layers/multinomial_logistic_loss_layer.cpp
CXX src/caffe/layers/mvn_layer.cpp
CXX src/caffe/layers/batch_norm_layer.cpp
CXX src/caffe/layers/cudnn_lcn_layer.cpp
CXX src/caffe/layers/power_layer.cpp
CXX src/caffe/layers/log_layer.cpp
CXX src/caffe/layers/absval_layer.cpp
CXX src/caffe/layers/conv_layer.cpp
CXX src/caffe/layers/bnll_layer.cpp
CXX src/caffe/layers/hdf5_data_layer.cpp
CXX src/caffe/layers/base_conv_layer.cpp
CXX src/caffe/layers/inner_product_layer.cpp
CXX src/caffe/layers/dummy_data_layer.cpp
CXX src/caffe/layers/prelu_layer.cpp
CXX src/caffe/layers/reduction_layer.cpp
CXX src/caffe/layers/argmax_layer.cpp
CXX src/caffe/layers/loss_layer.cpp
CXX src/caffe/layers/batch_reindex_layer.cpp
CXX src/caffe/layers/hinge_loss_layer.cpp
CXX src/caffe/layers/cudnn_tanh_layer.cpp
CXX src/caffe/layers/embed_layer.cpp
CXX src/caffe/layers/exp_layer.cpp
CXX src/caffe/layers/concat_layer.cpp
CXX src/caffe/layers/accuracy_layer.cpp
CXX src/caffe/layers/split_layer.cpp
CXX src/caffe/layers/relu_layer.cpp
CXX src/caffe/solver.cpp
CXX src/caffe/solvers/adam_solver.cpp
CXX src/caffe/solvers/sgd_solver.cpp
CXX src/caffe/solvers/rmsprop_solver.cpp
CXX src/caffe/solvers/nesterov_solver.cpp
CXX src/caffe/solvers/adadelta_solver.cpp
CXX src/caffe/solvers/adagrad_solver.cpp
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0-rc3
/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5
collect2: error: ld returned 1 exit status
Makefile:554: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
make: *
* [.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1
CXX tools/compute_image_mean.cpp
CXX tools/upgrade_net_proto_binary.cpp
CXX tools/extract_features.cpp
CXX tools/device_query.cpp
CXX tools/train_net.cpp
CXX tools/test_net.cpp
CXX tools/caffe.cpp
CXX tools/upgrade_solver_proto_text.cpp
CXX tools/net_speed_benchmark.cpp
CXX tools/finetune_net.cpp
CXX tools/upgrade_net_proto_text.cpp
CXX tools/convert_imageset.cpp
CXX examples/cifar10/convert_cifar_data.cpp
CXX examples/siamese/convert_mnist_siamese_data.cpp
CXX examples/mnist/convert_mnist_data.cpp
CXX examples/cpp_classification/classification.cpp
make: Target 'all' not remade because of errors.

Most helpful comment

I think the reason is you use make to compile, which makes caffe's python port only find libraries in this catalog. Maybe you use cmaketo compile and it could work.
make clean
cd caffe-master
mkdir build
cd build
cmake ..
make all -j8
I hope I could help you!

All 36 comments

maye "make -j4" instead?

Closing as this looks like a usage issue.

Please ask usage questions on caffe-users: https://groups.google.com/forum/#!forum/caffe-users

Thank you sir for your help !!

how did you solve this problem? @darshoka

comment both USE_CUDNN := 1 and CPU_ONLY := 1 in Makefile.config .Then apply cmake . command then make -j 4 all .

it works fine .

thank you, though it doesn't work for me.

I have the same problem and with this solution does not work, what you say to do please

I am receiving the following errors help me please:

LD -o .build_release/lib/libcaffe.so.1.0.0-rc5
CXX tools/compute_image_mean.cpp
CXX tools/upgrade_net_proto_text.cpp
CXX tools/train_net.cpp
/usr/bin/ld: 找不到 -lhdf5_hl
/usr/bin/ld: 找不到 -lhdf5
collect2: error: ld returned 1 exit status
Makefile:572: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc5' failed
make: * [.build_release/lib/libcaffe.so.1.0.0-rc5] Error 1

mine is the same problem :

AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0-rc4
/usr/bin/ld: cannot find -l -lopencv_core
/usr/bin/ld: cannot find -lopencv_imgcodecs
collect2: error: ld returned 1 exit status

i dont know what should i do?

hello! @LPCelite ,I have the same following errors when I make -j8. I want to ask you to answer,thank you!

nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0-rc5
/usr/bin/ld: cannot find -lopencv_imgcodecs
collect2: error: ld returned 1 exit status
make: * [.build_release/lib/libcaffe.so.1.0.0-rc5] Error 1
aicrobo@aicrobo:~/py-faster-rcnn/caffe-fast-rcnn$

@LPCelite

@darshoka hello! Can you help me to solve this problem?thank you!

nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0-rc5
/usr/bin/ld: cannot find -lopencv_imgcodecs
collect2: error: ld returned 1 exit status
make: * [.build_release/lib/libcaffe.so.1.0.0-rc5] Error 1
aicrobo@aicrobo:~/py-faster-rcnn/caffe-fast-rcnn$

When compiling with OpenCV 3.0 or errors show imread,imencode,imdecode or VideoCapture open your Makefile with some text editor, add opencv_imgcodecs behind.

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

(See the discussion at: https://github.com/BVLC/caffe/issues/1276)

the same problem

I think the reason is you use make to compile, which makes caffe's python port only find libraries in this catalog. Maybe you use cmaketo compile and it could work.
make clean
cd caffe-master
mkdir build
cd build
cmake ..
make all -j8
I hope I could help you!

@LazyAaron
Thank you! it work fine.
@donghongwen
You can follow the way as following:
make clean
cd caffe
mkdir build
cd build
cmake ..
make all -j4

@LPCelite
make clean
cd caffe
mkdir build
cd build
cmake ..
make all -j4
It works well but the problem is when import caffe
No module named caffe.
How do you add your module directory to your $PYTHONPATH in ~/.bashrc file.

I do
export PYTHONPATH=$home/ubuntu/caffe/build/python:$PYTHONPATH
It doesn't work.
Plz, help me with this.

i've just added the path of caffe's python to my python environment:
import sys
sys.path.append('/Caffe/python')
caffe_root = '/Caffe'

@LPCelite make clean
cd caffe
mkdir build
cd build
cmake ..
make all -j4
It works well but the problem is when import caffe
No module named caffe.

Are you using python wrapper. If so, you need make python wrapper as well. You also need make compiled python wrapper to python searching path.

My solution: ~$ vim .bashrc add: export PYTHONPATH=/home/xxxx/caffe/python:$PYTHONPATH to the file. sp: xxxx is you root name 发自网易邮箱手机版 On 2017-07-07 19:55 , mayyphyokhaing Wrote: @LPCelite make clean cd caffe mkdir build cd build cmake .. make all -j4 It works well but the problem is when import caffe No module named caffe. How do you add your module directory to your $PYTHONPATH in ~/.bashrc file. I do export PYTHONPATH=$home/ubuntu/caffe/build/python:$PYTHONPATH It doesn't work. Plz, help me with this. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

caffe cannot find -lboost_python3 library. You can try
cd /usr/lib/x86_64-linux-gnu/
sudo ln -s libboost_python-py34.so libboost_python3.so
to create a soft link for the library already in your computer with different name.

Try to add this to 'INCLUDE_DIRS' in your Makefile.config:
/usr/include/hdf5/serial/
@LPCelite

@Aaron9477
The problem is solved!
Thanks

@mayyphyokhaing I have fellow the method; I add my module directory to my $PYTHONPATH in the ~/.bashrc file. export PYTHONPATH=$home/ubuntu/caffe/python:$PYTHONPATH

@LPCelite
cd caffe
mkdir build
cd build
cmake ..

I ask for help. At the end, this error appears:

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

check your cuda and cudnn version & path

@Aaron9477 is right.
when you have compiled before, you should clean when you re-compile it.

Still I have error:

AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0-rc3
/usr/bin/ld: cannot find -lcblas
/usr/bin/ld: cannot find -latlas
collect2: error: ld returned 1 exit status
Makefile:555: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1

Still I have error:

AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0-rc3
/usr/bin/ld: cannot find -lcblas
/usr/bin/ld: cannot find -latlas
collect2: error: ld returned 1 exit status
Makefile:555: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1

so did you solve it?

Still I have error:

AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0-rc3
/usr/bin/ld: cannot find -lcblas
/usr/bin/ld: cannot find -latlas
collect2: error: ld returned 1 exit status
Makefile:555: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1

so did you solve it?

meet the same problem!!!

  • maybe you can use this sudo apt-get install libatlas-base-dev ,but i get another problem.

Thank you sir for your help !!

Whom are you thank you for? Which answer solves your problem?

When compiling with OpenCV 3.0 or errors show imread,imencode,imdecode or VideoCapture open your Makefile with some text editor, add opencv_imgcodecs behind.

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

(See the discussion at: #1276)

这个库里有 hdf5_hl hdf5,编译的时候说找不到

I have a same error but about -lpython3.5m :(

CXX examples/siamese/convert_mnist_siamese_data.cpp
CXX examples/mnist/convert_mnist_data.cpp
CXX examples/cifar10/convert_cifar_data.cpp
CXX examples/cpp_classification/classification.cpp
CXX .build_release/src/caffe/proto/caffe.pb.cc

AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0-rc3
/usr/bin/ld: cannot find -lpython3.5m
collect2: error: ld returned 1 exit status
Makefile:572: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1

Makefile.config:

# Verify anaconda location, sometimes it's in root.
ANACONDA_HOME := /home/iplab/anaconda3

PYTHON_INCLUDE := $(ANACONDA_HOME)/envs/pourkeshavarz_caffe_py35/include \
         $(ANACONDA_HOME)/envs/pourkeshavarz_caffe_py35/include/python3.5m \
         $(ANACONDA_HOME)/envs/pourkeshavarz_caffe_py35/lib/python3.5m/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.6m \
#                 /usr/lib/python3.6m/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

and I export CPLUS_INCLUDE_PATH by :
CPLUS_INCLUDE_PATH=/usr/include/python3.6

ubuntu 18.04
CUDA 10

Makefile:577: recipe for target '.build_release/src/caffe/util/upgrade_proto.o' failed
Any idea?

I think the reason is you use make to compile, which makes caffe's python port only find libraries in this catalog. Maybe you use cmaketo compile and it could work.
make clean
cd caffe-master
mkdir build
cd build
cmake ..
make all -j8
I hope I could help you!

I am stuck at cmake, I got this error

-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   system
--   thread
--   filesystem
--   chrono
--   date_time
--   atomic
-- Found gflags  (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libgflags.so)
-- Found glog    (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libglog.so)
-- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread (found version "3.0.0") 
-- 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 HDF5: /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_cpp.so;/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/libsz.so;/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libm.so (found version "1.10.0.1") found components:  HL 
-- Found LMDB: /usr/include  
-- Found lmdb    (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/liblmdb.so)
-- Found LevelDB: /usr/include  
-- Found LevelDB (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libleveldb.so)
-- Found Snappy: /usr/include  
-- Found Snappy  (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libsnappy.so)
-- CUDA detected: 10.1
-- Found cuDNN: ver. 7.6.5 found (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libcudnn.so)
-- Added CUDA NVCC flags for: sm_37
-- OpenCV found (/usr/share/OpenCV)
-- Found Atlas: /usr/include/x86_64-linux-gnu  
-- Found Atlas (include: /usr/include/x86_64-linux-gnu library: /usr/lib/x86_64-linux-gnu/libatlas.so lapack: /usr/lib/x86_64-linux-gnu/liblapack.so
-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.17", minimum required is "2.7") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so (found suitable version "2.7.17", minimum required is "2.7") 
-- Found NumPy: /usr/local/lib/python2.7/dist-packages/numpy/core/include (found suitable version "1.16.4", minimum required is "1.7.1") 
-- NumPy ver. 1.16.4 found (include: /usr/local/lib/python2.7/dist-packages/numpy/core/include)
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   python
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- Found Git: /usr/bin/git (found version "2.17.1") 
-- 
-- ******************* Caffe Configuration Summary *******************
-- General:
--   Version           :   1.0.0
--   Git               :   1.0-136-g9b891540-dirty
--   System            :   Linux
--   C++ compiler      :   /usr/bin/c++
--   Release CXX flags :   -O3 -DNDEBUG -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
--   Debug CXX flags   :   -g -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
--   USE_NCCL          :   OFF
--   ALLOW_LMDB_NOLOCK :   OFF
--   USE_HDF5          :   ON
-- 
-- Dependencies:
--   BLAS              :   Yes (Atlas)
--   Boost             :   Yes (ver. 1.65)
--   glog              :   Yes
--   gflags            :   Yes
--   protobuf          :   Yes (ver. 3.0.0)
--   lmdb              :   Yes (ver. 0.9.21)
--   LevelDB           :   Yes (ver. 1.20)
--   Snappy            :   Yes (ver. ..)
--   OpenCV            :   Yes (ver. 3.2.0)
--   CUDA              :   Yes (ver. 10.1)
-- 
-- NVIDIA CUDA:
--   Target GPU(s)     :   Auto
--   GPU arch(s)       :   sm_37
--   cuDNN             :   Yes (ver. 7.6.5)
-- 
-- Python:
--   Interpreter       :   /usr/bin/python2.7 (ver. 2.7.17)
--   Libraries         :   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.17)
--   NumPy             :   /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.16.4)
-- 
-- Documentaion:
--   Doxygen           :   No
--   config_file       :   
-- 
-- Install:
--   Install path      :   /content/drive/My Drive/Colab Notebooks/ai/mask_detection/caffe/install
-- 
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_cublas_device_LIBRARY (ADVANCED)
    linked by target "caffe" in directory /content/drive/My Drive/Colab Notebooks/ai/mask_detection/caffe/src/caffe

-- Configuring incomplete, errors occurred!
See also "/content/drive/My Drive/Colab Notebooks/ai/mask_detection/caffe/CMakeFiles/CMakeOutput.log".
See also "/content/drive/My Drive/Colab Notebooks/ai/mask_detection/caffe/CMakeFiles/CMakeError.log".

Also, I am seeing python2.7 here, whereas google colab has python3.6, please let me know how to fix this.

@amitjslearn
i meet this problem recently too. Update the cmake version(mine is 3.10->3.14) and it works.

Was this page helpful?
0 / 5 - 0 ratings