Runtime API error 30: unknown error

When I try do to a simple cudaMalloc I get “Runtime API error 30: unknown error”.

What can the error be?

The error only seems to occur when I’ve previously used the CUFFT library.


use CUFFT library, call next function, error 30
do not use CUFFT library, call next function, no error

Windows 7 64-bit, Visual studio 2010 professional, CUDA 4.2, Geforce GTX 460M

I run the code through Matlab mex (Matlab 2012a). I compile a lib-file in visual studio and then link it to a Matlab mex-file.

can you please provide a piece of code? The error might also come from another asynch call (e.g. kernel) unrelated to the alloc.

Well the whole program is about 11 000 lines…

I managed to get rid of the error by doing cudaDeviceReset, then re-allocating memory and copy data back from host. The error is clearly related to the CUFFT library, perhaps some dll needs to be cleared.

the cudaDeviceReset removes any pending error code. If there is a real bug in some kernel all you do is removing the error notification but not the source of the error.
I’d prefer to pinpoint the exact instructions/calls.

So what about adding some kind of

printf(“Cuda status: %s\n”, cudaGetErrorString( cudaGetLastError() ) )

right before and after your malloc inside your host code for debugging.
This way you can at least verify if the error source is indeed caused by the cudaMalloc. If the error pops up before the cudaMalloc, cudaMalloc is not the source, but the call that discovers the error.
Otherwise move the printfs along your code to find which call to cufft really makes this trouble.

When you write it is clearly related to the cufft lib, then you already know that the malloc is not the error source, but one of the other calls. Blaming the Malloc while finding this problem being related to cufft is most likely not the best bet.


I finally found the bug, it was a simple null pointer. I forgot that I in the FFT version deallocated one variable to save memory. Shame on me.