Debug using cuda-gdb

Overview

  • Time: 15 min

  • Learn how to use cuda-gdb for Debugging.

To debug a CUDA program, use cuda-gdb, NVIDIA’s debugger designed for CUDA C/C++ applications. It works similarly to gdb, but with additional support for GPUs.

To start compile the application with debug flags

1nvcc -G -g -o my_program my_program.cu

Explanation

  • -G: Includes debug information for device code

  • -g: Includes debug info for host code (like gcc)

Then launch the application with cuda-gdb

1cuda-gdb ./18_vector_add

Key Points

  • Debugging CUDA code is similar to debugging CPU code with gdb, but includes GPU-specific features.

  • Always ensure you are running the debug build when using cuda-gdb.