I\'m using Visual Studio 2010 and a GTX480 with compute capability 2.0.
I have tried setting sm to 2.0, but when I attempt to use printf() in a kernel, I get:
To use printf
in kernel code, you have to do three things:
cstdio
or stdio.h
are included in the kernel compilation unit. CUDA implements kernel printf
by overloading, so you must include that file-arch=sm_20
to nvcc or the IDE equivalent in Visual Studio or Nsight Eclipse edition)cudaDeviceSynchronize
for example). You are probably compiling for an architecture that does not support printf(). By default the project is compiled for compute architecture 1.0. To change this, in VS open the project properties -> CUDA C/C++ -> Device and change the "Code Generation" property to "compute_20,sm_20".
You do not need #include "util\cuPrintf.cu"
. Please see this for details on how to use printf and how to flush the output so you actually see the result.
If you're getting that error, it probably means that your GPU does not have Compute capability 2.x or higher. This thread goes into more detail on what your options are for printing inside a kernel function.