Memory Copy Issue

Hi :)

I have a kinda strange problem when copying memory:

I have a pretty big array of structs (8 byte large, well aligned(2* unsigned long)) located in the host memory. Then i allocate an array of the same size on the device (sometimes the screen completely freezes at this point…ugly). The size is about 50 Mb. I Copy it to the device, no problems - CudaSuccess.

after i worked on it, i try to Copy it back to the host, and everything gets currupted.
with a size of ~40 Mb this problem does not occur.

I’m just wondering, cause my global device memory is at 512 Mb (9800 GTX), and the border of where the error occurs seems not to be fixed. Important to know is maybe, that there is an opengl GUI in the program, with a graphical editor (some kind of CAD software)

===questions===

Is it possible, that i try to allocate too much device memory?
Is there an easy way to find out, how much device memory is free at a specific moment?
Does the Memory on the device need to be stored in 1 big block(when i allocate such a block), or does it automatically get seperated physically?
When the OpenGl program trys to get more device memory (maybe by adding a geometry obj. ect.), does this possibly overwrite the device memory allocated by the cuda code?

I noted, that cuda processing gets paused totally when any opengl jobs have to be done (zooming, rotating view ect.), can i change this prioritys?

thx for answers :)

Sounds suspiciously like this (from the Linux release notes):

the unsigned longs i use are defined as unsigned __int32. i use neither gcc nor linux, and it works pretty good when the size of the array is lower than 40 Mb (no errors, correct calculation), so the problem must be something else.

try “cuMemGetInfo”

unsigned int free_mem,total_mem, used_mem;

	cuMemGetInfo( &free_mem, &total_mem );

	used_mem = total_mem-free_mem;

	printf("before plan1d:total mem: %0.3f MB, free: %0.3f MB, used : %0.3f MB\n",

		((double)total_mem)/1024.0/1024.0,

		((double)free_mem )/1024.0/1024.0, 

		((double)used_mem )/1024.0/1024.0 );

you need to link with -lcuda

thanks, that may be helpful, but i get a linker error in VS2008 when i try to link to -lcuda or -cuda in the cuda command line setting. ;(

any idea where to put that line at? I’m not so experienced with the VS stuff, but need to use it ;(

solved … cuda.lib smashing my head against my table for several times

Very strange: free_mem gets a value of ~4300000, total_mem is only about 4290000

except for that this is a ridiculous low amount of memory (4 Mb O.o), this can impossibly be true…

used your code example with copy&paste ;(

cuMemGetInfo Returns the Value CUDA_ERROR_INVALID_CONTEXT…no idea what’s the reason, really ;(