const int malloc_limit = 4608*1024*1024;
error = cuCtxSetLimit(CU_LIMIT_MALLOC_HEAP_SIZE, malloc_limit);
if (error != CUDA_SUCCESS) Cleanup(false);
I tried this code to allocate 4.5GB heap size for malloc. Obviously, this won’t work because int is -2GB to 2GB. So how can I allocate 4.5GB? Is there a new flag to set it in KB or MB?
You should have been able to find a solution for that warning message by searching the web.
These should both get rid of the warning under 64-bit systems:
const size_t malloc_limit = size_t(4608) * size_t(1024) * size_t(1024);
const size_t malloc_limit = 4608ull * 1024ull * 1024ull;
Thank you very much for your reply. I added a (size_t) cast in front of the integers and it could compile without warning.
But I still couldn’t allocate more than 4GB heap size in practice. I run nvidia-smi along with my run. I noticed that no matter what I set above 409610241024, VRAM usage remains at 4192/6143MiB, If I set it below 409610241024, the number would change accordingly at nvidia-smi. What can I do?
I checked with the CUDA driver team. They confirmed that a hard 4 GB limit is currently in place. A bug has been filed. Sorry for the inconvenience and thank you for making us aware of this issue.