Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when compiling using cmake: contrastive_loss_layer.cpp: error: no matching function for call to 'max(float, double)' #60

Closed
aliko70 opened this issue Aug 22, 2017 · 7 comments

Comments

@aliko70
Copy link

aliko70 commented Aug 22, 2017

I am trying to compile your version of Caffe and miserably have faced this issue that I don't seem to be able to solve it. I appreciate hints from anyone.
Here's what I do:

  1. Installed all dependencies
  2. Changed Make.config file to use only cpu with python layer = 1
  3. cmake --cmake -DCPU_ONLY=ON .. (And bellow is cmake configuration summary):

-- ******************* Caffe Configuration Summary *******************
-- General:
-- Version : (Caffe doesn't declare its version in headers)
-- Git : 1595004-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 : ON

-- Dependencies:
-- BLAS : Yes (Atlas)
-- Boost : Yes (ver. 1.62)
-- glog : Yes
-- gflags : Yes
-- protobuf : Yes (ver. 3.0.0)
-- lmdb : Yes (ver. 0.9.18)
-- Snappy : Yes (ver. 1.1.3)
-- LevelDB : Yes (ver. 1.18)
-- OpenCV : Yes (ver. 2.4.9.1)
-- CUDA : No

-- Python:
-- Interpreter : /usr/bin/python2.7 (ver. 2.7.13)
-- Libraries : /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.13)
-- NumPy : /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.12.1)

-- Documentaion:
-- Doxygen : No
-- config_file :

-- Install:
-- Install path : /data/CTPN/caffe/build/install

-- Configuring done
-- Generating done
-- Build files have been written to: /data/CTPN/caffe/build

  1. make all -j4 (results in the following error):

[ 14%] Building CXX object src/caffe/CMakeFiles/caffe.dir/layers/contrastive_loss_layer.cpp.o
[ 14%] Building CXX object src/caffe/CMakeFiles/caffe.dir/layers/conv_layer.cpp.o
/home/CTPN/caffe/src/caffe/layers/contrastive_loss_layer.cpp: In instantiation of 'void caffe::ContrastiveLossLayer::Forward_cpu(const std::vector<caffe::Blob>&, const std::vector<caffe::Blob>&) [with Dtype = float]':
/home/CTPN/caffe/src/caffe/layers/contrastive_loss_layer.cpp:118:1: required from here
/home/CTPN/caffe/src/caffe/layers/contrastive_loss_layer.cpp:56:30: error: no matching function for call to 'max(float, double)'
Dtype dist = std::max(margin - sqrt(dist_sq_.cpu_data()[i]), 0.0);
~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have managed and used original version of caffe. Although I faced all types of error during its compilation, except this one.

Many thanks in advance.

@aliko70
Copy link
Author

aliko70 commented Aug 24, 2017

The issue was with gcc and g++ versions. I downgraded them from version 6 to 5 and that solved the problem

@aliko70 aliko70 closed this as completed Aug 24, 2017
@fwang18
Copy link

fwang18 commented Nov 8, 2017

Hi, I have encountered same question, but downgrade gcc doesn't solve the problem. Can you be more specific?

@Yannick-ll
Copy link

Hi fwang18,
Replace line 56 by this one :
Dtype dist = std::max(margin - (float)sqrt(dist_sq_.cpu_data()[i]), Dtype(0.0));

Casting output of 'sqrt' function solved the problem for me.

@JeasonUESTC
Copy link

Hello, I have encountered the same problem in the learning process. How did you solve it?Thank you.

@Viliami
Copy link

Viliami commented Jun 25, 2019

In my case, casting to double worked for me.
Dtype dist = std::max(margin - (double)sqrt(dist_sq_.cpu_data()[i]), Dtype(0.0));

@zhuqiming678
Copy link

    Dtype dist = std::max<Dtype>(margin - sqrt(dist_sq_.cpu_data()[i]), Dtype(0.0));

1 similar comment
@zhuqiming678
Copy link

    Dtype dist = std::max<Dtype>(margin - sqrt(dist_sq_.cpu_data()[i]), Dtype(0.0));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants