title: CUDA kernel printf() produces no output in terminal, works in profiler
body: <p>Consider the following program:</p>
  
  <pre><code>#include &lt;cuda/api_wrappers.hpp&gt;
  
  namespace kernels {
  template &lt;typename T&gt;
  __global__ void print_stuff()
  {
          printf("This is a plain printf() call.\n");
  }
  } // namespace kernels
  
  int main()
  {
          auto launch_config { cuda::make_launch_config(2,2) };
          cuda::launch(::kernels::print_stuff&lt;int&gt;, launch_config);
          cuda::outstanding_error::ensure_none();
  }
  </code></pre>
  
  <p>(it uses the <a href="https://github.com/eyalroz/cuda-api-wrappers" rel="nofollow noreferrer">cuda-api-wrappers</a> library).</p>
  
  <p>The program compiles and runs. However, if I run in in a terminal, it prints nothing;
  while if I run it via nvvp, the console shows me:</p>
  
  <pre><code>This is a plain printf() call.
  This is a plain printf() call.
  This is a plain printf() call.
  This is a plain printf() call.
  </code></pre>
  
  <p>... as expected (2 blocks x 2 threads = 4 lines).</p>
  
  <p>What is/could be the reason am I not getting the four lines printed on the terminal as well?</p>
  
  <p>Notes:</p>
  
  <ul>
  <li>I realize the fault may theoretically be with the library, of which I am the author. So "it has to be the library" is a legitimate answer, but you need to explain why it can't be anything else.</li>
  <li>No warnings when compiling with <code>nvcc -Xcompiler -Wall -Xcompiler -Wextra</code>.</li>
  <li>I use Devuan GNU/Linux 3 (beowulf; equivalent of Debian Buster).</li>
  <li>My hardware: An AMD64 Intel CPU; a GTX 1050 Ti card.</li>
  <li>nVIDIA Driver version: 430.50; CUDA version: 10.1.105 .</li>
  <li><code>cuda-memcheck</code> does not complain about the program.</li>
  </ul>