我正在使用DDT调试一个基于MPI的CUDA程序。当在我的代码中从cudaMalloc和cudaThreadSynchronize (更新:使用cudaDeviceSynchronize )调用时,当CUDA运行时库(libcudart)在(未记录的)函数cudaGetExportTable中抛出异常时,我的代码中止。
为什么libcudart在通过cudaError_t返回值或CHECKCUDAERROR在我的代码中检测到异常之前抛出异常(我使用的是can,而不是C++ API
(我使用的是用于Linux的CUDA 4.2 SDK。)
输出:
Process 9: terminate called after throwing an instance of 'cudaError_enum'
Process 9: terminate called recursively
Process 20: terminate called after throwing an instance of 'cudaError'
Process 20: terminate called recursively我的代码:
cudaThreadSynchronize();
CHECKCUDAERROR("cudaThreadSynchronize()");其他代码片段:
const size_t t; // from argument to function
void* p=NULL;
const cudaError_t r=cudaMalloc(&p, t);
if (r!=cudaSuccess) {
ERROR("cudaMalloc failed.");
}部分回溯:
Process 9:
cudaDeviceSynchronize()
-> cudaGetExportTable()
-> __cxa_throw
Process 20:
cudaMalloc()
-> cudaGetExportTable()
-> cudaGetExportTable()
-> __cxa_throw内存调试错误:
Processes 0,2,4,6-9,15-17,20-21:
Memory error detected in Malloc_cuda_gx (cudamalloc.cu:35):
dmalloc bad admin structure list. 这一行是上面显示的cudaMalloc代码片段。另外:
Processes 1,3,5,10-11,13-14,18-19,23:
Memory error detected in vfprintf from /lib64/libc.so.6:
dmalloc bad admin structure list.此外,当在每个节点上运行3个核心/ gpus而不是每个节点4个gpus时,dmalloc会检测类似的内存错误,但当不在调试模式下时,代码在每个节点3个gpus上运行得非常好(据我所知)。
发布于 2012-07-28 05:34:31
和gcc一起重新编译。(我正在使用icc编译我的代码。)
当你这样做的时候,异常会在调试时出现,但如果超过它,我就会得到真正的CUDA错误:
Process 9: gadget_cuda_gx.cu:116: ERROR in gadget_cuda_gx.cu:919: CUDA ERROR: cudaThreadSynchronize(): unspecified launch failure
Process 20: cudamalloc.cu:38: ERROR all CUDA-capable devices are busy or unavailable, cudaMalloc failed to allocate 856792 bytes = 0.817101 MbValgrind在我的代码中没有发现内存损坏或泄漏(无论是使用gcc还是icc编译),但确实在libcudart中发现了一些泄漏。
更新:仍未修复。似乎与答案#2中报告的问题相同:cudaMemset fails on __device__ variable。运行时似乎没有像它应该的那样工作。
https://stackoverflow.com/questions/11635093
复制相似问题