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

2 errors detected in the compilation of "/tmp/tmpxft_000027fb_00000000-12_math_functions.compute_35.cpp1.ii". #769

Closed
shiorioxy opened this issue Jul 23, 2014 · 4 comments

Comments

@shiorioxy
Copy link

When I execute the command $ make all, I receive a error message
Help me, thank you!

/usr/local/cuda/bin/nvcc -ccbin=/usr/bin/g++ -Xcompiler -fPIC -DNDEBUG -O2 -DUSE_MKL -I/usr/local/include/python2.7 -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/include -Ibuild/src -I./src -I./include -I/usr/local/cuda/include -I/opt/intel/mkl/include -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 -c src/caffe/util/math_functions.cu -o build/src/caffe/util/math_functions.cuo
src/caffe/util/math_functions.cu(140): error: calling a host function("std::signbit ") from a global function("caffe::sgnbit_kernel ") is not allowed

src/caffe/util/math_functions.cu(140): error: calling a host function("std::signbit ") from a global function("caffe::sgnbit_kernel ") is not allowed

2 errors detected in the compilation of "/tmp/tmpxft_000027fb_00000000-12_math_functions.compute_35.cpp1.ii".
make: *** [build/src/caffe/util/math_functions.cuo] Error 2

@Yangqing
Copy link
Member

Seems that math_functions.cu is calling cuda's signbit instead of std::signbit, so maybe you are compiling a version different from the current master or dev head?

@shiorioxy
Copy link
Author

thank you! 
I fixed the problem with your help.
But I have been download the current master version, maybe it is a little bug.

yajiedesign added a commit to yajiedesign/caffe that referenced this issue Jul 25, 2014
@Yangqing
Copy link
Member

Glad it works :) I wasn't reading the code carefully enough apparently. Closing this one and will address the pull request separately.

@night-zhang
Copy link

You can add macro judgment before atomicAdd.Open the file ./include/caffe/common.cuh and change it to

// Copyright 2014 George Papandreou

#ifndef CAFFE_COMMON_CUH_
#define CAFFE_COMMON_CUH_

#include <cuda.h>


// CUDA: atomicAdd is not defined for doubles

#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 600 
#else
static __inline__ __device__ double atomicAdd(double *address, double val) {
  unsigned long long int* address_as_ull = (unsigned long long int*)address;
  unsigned long long int old = *address_as_ull, assumed;
  if (val==0.0)
    return __longlong_as_double(old);
  do {
    assumed = old;
    old = atomicCAS(address_as_ull, assumed, __double_as_longlong(val +__longlong_as_double(assumed)));
  } while (assumed != old);
  return __longlong_as_double(old);
}

#endif
#endif

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

3 participants