cuda-gdb crashes and device printf()

So I’ve found CUDA debugging to be… infuriating at best. cuda-gdb crashes every time for me, and I’ve never been able to get device printf() to work. This makes it nearly impossible to debug kernel launch failures. Does anybody have solutions to these problems?

I’m running the most recent CUDA 3.2 release with the most recent dev drivers on Fedora 14 with a GTX 470. These problems have happened to me on every machine I’ve tried to write CUDA code on (not just this one).

Any time I try to run my CUDA programs in cuda-gdb, it just crashes with a BACKTRACE message, like so:

[bsomers@tyrol] > cuda-gdb hasteD 

NVIDIA (R) CUDA Debugger

3.2 release

Portions Copyright (C) 2008-2010 NVIDIA Corporation

GNU gdb 6.6

Copyright (C) 2006 Free Software Foundation, Inc.

GDB is free software, covered by the GNU General Public License, and you are

welcome to change it and/or distribute copies of it under certain conditions.

Type "show copying" to see the conditions.

There is absolutely no warranty for GDB.  Type "show warranty" for details.

This GDB was configured as "x86_64-unknown-linux-gnu"...

Using host libthread_db library "/lib64/libthread_db.so.1".

(cuda-gdb) r scene.lua 

Starting program: /home/bsomers/haste/hasteD scene.lua

BFD: /lib64/libc.so.6: invalid relocation type 37

BFD: BFD 2.17.50 assertion fail /home/buildmeister/build/rel/gpgpu/toolkit/r3.2/debugger/cuda-gdb/bfd/elf64-x86-64.c:259

BFD: /lib64/libc.so.6: invalid relocation type 37

BFD: BFD 2.17.50 assertion fail /home/buildmeister/build/rel/gpgpu/toolkit/r3.2/debugger/cuda-gdb/bfd/elf64-x86-64.c:259

[Thread debugging using libthread_db enabled]

[New process 15781]

Loading scene file...

Searching for CUDA devices...

[New Thread 139811079239488 (LWP 15781)]

	[0] GeForce GTX 470 (2.0, 448 cores, 1.22 GHz, 1279.19 MB)

Launching 1 control threads...

[New Thread 139811067307776 (LWP 15785)]

[0] Initializing device...

BACKTRACE (4 frames):

cuda-gdb[0x45a5ae]

/lib64/libc.so.6[0x333b834100]

cuda-gdb[0x528976]

cuda-gdb[0x5289bd]

In addition, when I try to compile with printf’s in my device code, I can’t seem to figure out which files I need to include. Where is the device printf defined?

Thanks for your help.

You need to include stdio.h to use printf in kernels.

Thanks, it seems to be working now. I was guessing it couldn’t be that simple since stdio.h doesn’t define printf() for device code, but I guess nvcc is doing some magic behind the scenes to rewrite those calls in my kernel. :smile:

Now I just need to figure out why cuda-gdb crashes all the time…

Wow, device printf()?, since when it is possible? is it a Fermi thing, or plainly Emulation mode makes it possible? If its not fermi and not Emu than how it works exactly?

Thanks in advance!

Native device printf is a Fermi thing and has been in the CUDA toolkit since Fermi was released (so 3.0 IIRC).

Can you please send source code for the app that is causing cuda-gdb to crash? You can email it to CUDA-debugger-bugs@nvidia.com