Borrar filtros
Borrar filtros

Debugging CUDA MEX in VS2017 (v2)

3 visualizaciones (últimos 30 días)
Vyacheslav Samokhvalov
Vyacheslav Samokhvalov el 19 de Mzo. de 2021
Editada: Joss Knight el 24 de Mzo. de 2021
Hello,
I'm going to mirror a question asked two years because I've run into a similar issue :
I've also asked this question at NVIDIA developper forum and will include the link for cross reference:
I've run into "CUDA_ERROR_ILLEGAL_ADDRESS", and using the host side debugger identified that it occurs when I try to fetch data back from the GPU while invoking "mxGPUCreateMxArrayOnCPU()". I would like to enter debugging mode inside the kernel to follow what is happening device side but I can't use the legacy debugger via VS2017 because it does not support my graphics card, and the next-gen debugger does not support remote debugging.
Does anyone know a workaround about this without having to resort to print statements?
Thanks in advance
  1 comentario
Joss Knight
Joss Knight el 24 de Mzo. de 2021
Editada: Joss Knight el 24 de Mzo. de 2021
First, synchronize using cudaDeviceSynchronize(), then call cudaGetLastError() and make sure the error hasn't actually already occurred before you call mxGPUCreateMxArrayOnCPU. Hamza's suggestion of cuda-memcheck is a good idea. If everything is fine then you might want to post your kernel code here for us to debug by inspection.

Iniciar sesión para comentar.

Respuesta aceptada

Hamza Butt
Hamza Butt el 23 de Mzo. de 2021
According to NVIDIA's release notes for Nsight Compute, support for Pascal GPUs has been removed since 2020.1. Also, as you mentioned, remote debugging is not currently supported with Nsight Compute's next gen debugger. This is more suited for NVIDIA's forum, as the question is generic to debugging device-side CUDA C++, with or without MATLAB. However, I will try to help as much as I can, though this is a difficult question for someone outside NVIDIA. MATLAB does not include a debugger for GPU code, instead it relies on third party debugging tools for the CUDA infrastructure, and only NVIDIA can answer this question definitively.
Of the ideas that I can think of: Try using an older version of Nsight compute that does support your GPU, to see if it works. Maybe you can use cuda-gdb directly? If you think you are leaking memory, try compiling in debug mode and running it through cuda-memcheck. This should identify the location of code where it thinks you are leaking memory.
  1 comentario
Vyacheslav Samokhvalov
Vyacheslav Samokhvalov el 23 de Mzo. de 2021
Editada: Vyacheslav Samokhvalov el 23 de Mzo. de 2021
Thank you for your answer!
For some reason somewhere between invoking mxGPUCopyFromMxArray, mxGPUGetData to work on the underlying data, and copying data back wtih mxGPUCreateMxArrayOnCPU there's unexpected behaviour. Because I cannot inspect what was happening on device code, to solve this issue I avoid using mxGPUArrays altogether, get pointers to data in Matlab arrays with mxGetSingles, do work with them in an outside CUDA library, and write data back to Matlab's mxArray.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre GPU Computing en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by