CuFFT :: Invalid Plan

I have Nvidia 8800 GTS on my 2.8GHz system.

I tried the CuFFT library with this short code.

It works fine for all the size smaller then 4096, but fails otherwise.

cufft: ERROR: D:/Bld/rel/gpgpu/toolkit/r2.1/cufft/src/config.cu, line 331

cufft: ERROR: CUFFT_ALLOC_FAILED

cufftSafeCall() CUFFT error in file <simpleCUFFT.cu>, line 193
void runTest(int argc, char** argv) 

{

	int NX = 4096;

	int NY = 4096;

	if( cutCheckCmdLineFlag(argc, (const char**)argv, "device") )

		cutilDeviceInit(argc, argv);

	else

		cudaSetDevice( cutGetMaxGflopsDeviceId() );

	Complex* h_idata = (Complex*)malloc(sizeof(Complex) * NX * NY);

	cufftHandle plan;

	cufftComplex *idata, *odata;

	cutilSafeCall(	cudaMalloc((void**)&idata, sizeof(cufftComplex)*NX*NY));

	cutilSafeCall(cudaMalloc((void**)&odata, sizeof(cufftComplex)*NX*NY));

	// Copy host memory to device

	cutilSafeCall(cudaMemcpy(idata, h_idata,sizeof(Complex) *  NX * NY, cudaMemcpyHostToDevice));

	/* Create a 2D FFT plan. */

	cufftSafeCall(cufftPlan2d(&plan, NX, NY, CUFFT_C2C));

	for(int i=0;i<10;i++)

		/* Use the CUFFT plan to transform the signal out of place. */

		cufftSafeCall(cufftExecC2C(plan, idata, odata , CUFFT_FORWARD));

	cufftSafeCall(cufftDestroy(plan));

	cutilSafeCall(cudaFree(idata)); 

	cutilSafeCall(cudaFree(odata));

}

You are likely running out of memory. Your card may have as little as 256MB of memory. 8k x 8k x sizeof(cufftComplex) = 536,870,912.

Actually, I am running into the same issue on GeForce 9800 GX2. When I try to run essentially the same code as in the original post with 4096x4096 transform size I get the same errors:

cufft: ERROR: D:/Bld/rel/gpgpu/toolkit/r2.2/cufft/src/config.cu, line 315
cufft: ERROR: CUFFT_ALLOC_FAILED
cufft: ERROR: D:/Bld/rel/gpgpu/toolkit/r2.2/cufft/src/cufft.cu, line 143
cufft: ERROR: CUFFT_INVALID_PLAN
cufft: ERROR: D:/Bld/rel/gpgpu/toolkit/r2.2/cufft/src/cufft.cu, line 143
cufft: ERROR: CUFFT_INVALID_PLAN
cufft: ERROR: D:/Bld/rel/gpgpu/toolkit/r2.2/cufft/src/cufft.cu, line 122
cufft: ERROR: CUFFT_INVALID_PLAN

Memory should not be an issue as 40964096sizeof(cufftComplex) is 128MB while GeForce 9800 GX2 has 512MB of memory.