Printf gives memory access error and behaves weirdly

Hi @huyleq1989,

Do you have a lot of output? printf support relies on a CUDA buffering system, and it only has a small buffer, so easy to run out of buffer space which will truncate your output. See this thread Size of printf buffer

It’s ideal to limit your printf output to a small amount, perhaps ideally by passing in the thread index to your kernel that you’d like debug, and only invoking printf when your thread index matches the parameter. Personally I like to wire up my thread index to a mouse click and/or a command line parameter to my application, to make it easy to dynamically set the pixel I’m interested in.


David.

1 Like