cudaMalloc always gives out of memory

China☆狼群 提交于 2019-12-05 18:25:41

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.

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.

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