compile DeepLab_v2 on Ubuntu 14.04.5 with Cuda 8.0

Problem:

error: function "atomicAdd(double *, double)" has already been defined

Somebody get this error while trying to compile the cafffe derivative DeepLab_v2 on Ubuntu 14.04.5 with Cuda 8.0.

Maybe DeepLab_v2 compiles fine on another computer that has Cuda 7.5.

Solution:

Analysis:

CUDA 8.0 provides a definition of atomicAdd on double quantities that was not present in previous CUDA toolkits. The code you are working with also apparently provides its own definition/implementation, and this is the source of the error message. The correct fix is to make source code changes to the software in question to make it compatible with CUDA 8. –Robert Crovella

How to do:

The solution provided by @Robert Crovella works for me. I had to modify the file common.cuh from the DeepLab_v2 master branch in the following way:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef CAFFE_COMMON_CUH_
#define CAFFE_COMMON_CUH_
#include <cuda.h>
#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

Contents
  1. 1. Problem:
  2. 2. Solution:
    1. 2.1. Analysis:
    2. 2.2. How to do:
|