Skip to content

Instantly share code, notes, and snippets.

@adujardin
Last active May 19, 2025 10:44
Show Gist options
  • Save adujardin/2a45b32109be85e49f0edd17306be326 to your computer and use it in GitHub Desktop.
Save adujardin/2a45b32109be85e49f0edd17306be326 to your computer and use it in GitHub Desktop.
Debugging cuda cheat sheet

Debugging CUDA exe

  1. Set CUDA as Synchronous mode: export CUDA_LAUNCH_BLOCKING=1
  2. Use CUDA GDB :
/usr/local/cuda/bin/cuda-gdb --arg foo arg1 arg2

Enable GDB option :

(cuda-gdb) set cuda api_failures stop

More details:

(cuda-gdb) help set cuda

Run your program:

(cuda-gdb) run

Once you hit an issue, check the backtrace

(cuda-gdb) bt

To avoid calling this everytime:

Create a .gdb file like ~/debug_setup.gdb:

set confirm off
set cuda api_failures stop
run

then

cuda-gdb -x ~/debug_setup.gdb ./your_app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment