由于做实验用到了matconvnet,而实验室的机子安装的版本是cuda8.0,在编译matconvnet的gpu版本时,遇到了
error: function “atomicAdd(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