Getting the available device memory

Hello CUDA Experts,

How do I get the available Device memory in my CUDA program?

Also, how much of the device memory can I allocate? Can I allocate all of the available device memory?

thanks,
PP

CUresult cuMemGetInfo(unsigned int* free, unsigned int* total);

Is what you’re looking for. About how much you can allocate, I’m guessing you can allocate all of global memory, but I haven’t tried that yet.

This works for the Driver API, but if you’re using the Runtime API it’s also sometimes possible to use this method, you may be interested in a post I raised a few days ago with some additional discussion at [url=“http://forums.nvidia.com/index.php?showtopic=81511”]http://forums.nvidia.com/index.php?showtopic=81511[/url]