在matlab2014b和cuda8.0的条件下编译MatConvNet

由于做实验用到了matconvnet,而实验室的机子安装的版本是cuda8.0,在编译matconvnet的gpu版本时,遇到了

error: functionatomicAdd(double *, double)” has already been defined

这个错误。
这个错误的产生是cuda8.0里面也定义了这个函数,所以出现了冲突。
解决方法是
如果MatConvNet版本在beta22以下,我的是18。你需要修改源代码,matlab/scr/bits/impl/文件夹下的pooling_gpu.cu第165行的 atomicAdd函数 ,修改方式如下:

#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 600
#else
<... place here your own pre-pascal atomicAdd definition ...>
#endif

例如:


// an implementation of atomicAdd() for double (really slow)
__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;
  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

其他的就按照官网
http://www.vlfeat.org/matconvnet/install/
就可以了。

参考网址:
http://stackoverflow.com/questions/37566987/cuda-atomicadd-for-doubles-definition-error

http://webcache.googleusercontent.com/search?q=cache:R_jOtfLQWuYJ:www.p-chao.com/en/%25E6%25B7%25B1%25E5%25BA%25A6%25E5%25AD%25A6%25E4%25B9%25A0/2016-12-28/matconvnet%25E6%25B7%25B1%25E5%25BA%25A6%25E5%25AD%25A6%25E4%25B9%25A0%25E6%25A1%2586%25E6%259E%25B6%25E7%25AE%2580%25E4%25BB%258B%25E5%258F%258Agpu%25E4%25BD%25BF%25E7%2594%25A8%25E6%25B3%25A8%25E6%2584%258F%25E4%25BA%258B%25E9%25A1%25B9.html+&cd=10&hl=en&ct=clnk&gl=hk

http://stackoverflow.com/questions/39274472/error-function-atomicadddouble-double-has-already-been-defined

你可能感兴趣的:(其他)