allocate the biggest possible array

Hi All!

I need to preallocate an array which should be as big as possible in CUDA with cudaMallocArray/cudaMalloc.
How can I do that? - It seems that if I allocate a too big array any subsequent call to any cuda function won’t work (therefore trying to allocate/free until I run into an error won’t work).

Thanks,

Greg

There is a call to ask for the amount of available memory. I believe it is cuMemGetInfo.

THanks for the suggestion, but counln’t this amount of memory be non-contiguous?

What I do is ask for all the RAM the device has. The alloc will fail, and then I just try for 98% of the failed alloc. Repeat until finally the alloc succeeds. This will quickly find and allocate the largest chunk available. You can keep repeating to find the second biggest block, and so on.

I used this when I made a hack “memtest” program to check for memory corruption when varying my memory clock. Sort of like a GPU version of memtest86.

That’s what I wanted to do… However, after a failed call to cudaMalloc any subsequent cuda function fails, so I don’t know what to do in that case? is it possible to reinitialize the GPU or something?

Thanks,

Greg