码迷,mamicode.com
首页 > 其他好文 > 详细

include/caffe/common.cuh(9): error: function "atomicAdd(double *, double)" has already been defined

时间:2017-10-04 15:17:36      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:ror   else   caff   return   device   size   print   col   cas   

编译caffe时出现:

include/caffe/common.cuh(9): error: function "atomicAdd(double *, double)" has already been defined

原因是CUDA 8.0 提供了对atomicAdd函数的定义,但atomicAdd在之前的CUDA toolkit中并未出现,因此一些程序自定义了atomicAdd函数。

解决方法:打开./include/caffe/common.cuh文件,在atomicAdd前添加宏判断即可。

改为如下所示:

 1 #ifndef CAFFE_COMMON_CUH_
 2 #define CAFFE_COMMON_CUH_
 3 
 4 #include <cuda.h>
 5 
 6   #if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 600
 7 
 8   #else
 9   static __inline__ __device__ double atomicAdd(double *address, double val) {
10     unsigned long long int* address_as_ull = (unsigned long long int*)address;
11     unsigned long long int old = *address_as_ull, assumed;
12     if (val==0.0)
13       return __longlong_as_double(old);
14     do {
15       assumed = old;
16       old = atomicCAS(address_as_ull, assumed, __double_as_longlong(val +__longlong_as_double(assumed)));
17     } while (assumed != old);
18     return __longlong_as_double(old);
19   }
20 
21 
22   #endif
23 #endif

 

include/caffe/common.cuh(9): error: function "atomicAdd(double *, double)" has already been defined

标签:ror   else   caff   return   device   size   print   col   cas   

原文地址:http://www.cnblogs.com/go-better/p/7625546.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!