cudaMalloc always gives out of memory

二次信任 提交于 2019-12-10 09:47:06

问题


I'm facing a simple problem, where all my calls to cudaMalloc fail, giving me an out of memory error, even if its just a single byte I'm allocating.

The cuda device is available and there is also a lot of memory available (bot checked with the corresponding calls).

Any idea what the problem could be?


回答1:


Please try to call cudaSetDevice(), then cudaDeviceSynchronize() and then cudaThreadSynchronize() at the beginning of the code itself.

cudaSetDevice(0) if there is only one device. by default the CUDA run time will initialize the device 0.

cudaSetDevice(0);
cudaDeviceSynchronize();
cudaThreadSynchronize();

Please reply back your observation. If still it is getting failed, please specify the OS, architecture, CUDA SDK version, CUDA driver version. if possible please provide the code/code snippet which is being failed.




回答2:


Thank you everybody for your help.

The problem was not really with the cudaMalloc itself but it shadowed the real problem which was due to the initialisation of cuda which seemed to fail.

Because the first call to cuda was in a separate Thread I did'nt have a GLContext available, leading to failures. I needed to make sure that I initialised cuda by a dummy malloc in the main thread after the initialisation of the context.



来源:https://stackoverflow.com/questions/13940600/cudamalloc-always-gives-out-of-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!