Problems calling new operator in CUDA 4.0

Greetings. I’m a newcomer to the CUDA world, so I’d be grateful for some help with a simple question.

I’m trying to use the new operator in CUDA 4.0, inside a device function, but the compiler is scolding me that this is a host function. The exact code is:

device ANNpoint annAllocPt(int dim, ANNcoord c) // allocate 1 point
ANNpoint p = new ANNcoord[dim];
for (int i = 0; i < dim; i++) p[i] = c;
return p;

and the error message is:

1>e:/Fermi/ (col. 11): error: calling a host function("operator new ") from a device/global function(“annAllocPt”) is not allowed

Device-side “new” requires compute capability >= 2.0 . Are you trying to build for a platform less than sm_20 / compute_20 by any chance ?

Yup, that was the problem, Thanks.

I am getting the same problem and I have a 3.0 compute capability, anyone knows what is going on?
Code is as follows:

#ifdef __CUDACC__
#define CUDA_CALLABLE_MEMBER __host__ __device__

class Foo {
    CUDA_CALLABLE_MEMBER void aMethod() {}
__global__ void Kernel()
	Foo* f = new Foo();

Are you building for compute capability 3.0? The compiler defaults to compute capability 1.0. Pass


to build the code for compuite capability 3.0.