Improved memory usage calculations in CUDA backend