Memory Size

there is a cuMemGetInfo function which will let you query the total memory and the free memory on the device before you call cudaMalloc. (Even though cuMemGetInfo is technically part of the driver API, you can safely use it from the Runtime API as well.)