如何在检测到Cuda API错误时找到程序崩溃的位置:cudaMemcpy返回(0xb)

时间:2016-02-19 18:54:17

标签: c++ cuda cuda-gdb

我正在调试cuda程序并收到以下警告:

warning: Cuda API error detected: cudaMemcpy returned (0xb)

warning: Cuda API error detected: cudaMemcpy returned (0xb)

warning: Cuda API error detected: cudaGetLastError returned (0xb)

Error in kernel
GPUassert: invalid argument

当我在cuda-gdb中键入“where”时,它表示“没有堆栈。”

(cuda-gdb) where
No stack.

应该如何找到程序崩溃的位置?

1 个答案:

答案 0 :(得分:3)

在此处找到答案:http://on-demand.gputechconf.com/gtc/2012/presentations/S0027A-Monday-Debugging-Experience-CUDA.pdf @第27页。

您需要先:

(cuda-gdb) set cuda api_failures stop

然后当错误发生时,它将停止:

Cuda API error detected: cudaMemcpy returned (0xb)
(cuda-gdb) where
#0  0x00007fffea6a06d0 in cudbgReportDriverApiError () from       /usr/lib64/nvidia/libcuda.so.1
#1  0x00007fffea6a2c36 in cudbgReportDriverInternalError () from /usr/lib64/nvidia/libcuda.so.1
#2  0x00007fffea6eed93 in cudbgGetAPIVersion () from /usr/lib64/nvidia/libcuda.so.1
...