Hi,
I’m implementing a CUDA extension to be used inside Python code. However I’m getting a strange error and I’m having trouble to debug it.
The caller of the CUDA kernel uses this code:
dim3 grid_dim(94, 94, 6);
dim3 block_dim(64);
kernel<<grid_dim, block_dim>>(params...)

For some reason, I’m getting this error:
/opt/conda/conda-bld/pytorch_1544174967633/work/aten/src/ATen/native/cuda/IndexKernel.cu:53: lambda [](int)->auto::operator()(int)->auto: block: [45,0,0], thread: [95,0,0] Assertion `index >= -sizes[i] && index < sizes[i] && "index out of bounds"` failed.
RuntimeError: merge_sort: failed to synchronize: device-side assert triggered

With that in mind, I have two questions:

If the block dimensions (how many threads are in a block) are (64,1,1), should I get this “thread: [95,0,0]”? Isn’t 95 out of the range of the block dimensions?
How can I debug a CUDA kernel inside Python code? (I usually use pdb for debugging python code, gdb for C++, or cuda-gbc for CUDA code, but I didn’t find a way to debug CUDA coda surrounded by a python wrapper. I thought about writing a test case just in CUDA, but then I need to compile it by hand and link Aten and other libraries by myself).

I welcome any suggestions that you may have.
Thank you,