not able to use printf in cuda kernel function

前端 未结 2 1534
陌清茗
陌清茗 2020-12-21 10:54

It seems that printf doesn\'t work inside the Kernel of a cuda code

#include \"Common.h\"
#include
#include 

__dev         


        
相关标签:
2条回答
  • 2020-12-21 11:11

    You need to use cuPrintf, as in this example. Note that printf is a pretty limited way of debugging, the Nsight or Nsight eclipse edition IDEs are much nicer.

    0 讨论(0)
  • 2020-12-21 11:28

    Quoting the CUDA Programming Guide "Formatted output is only supported by devices of compute capability 2.x and higher". See the programming guide for additional information.

    Devices of compute capability < 2.x can use cuPrintf.

    If you are on a 2.x and above device and you are trying to use printf make sure you have specified arch=sm_20 (or higher). The default is sm_10 which does not have sufficient features to support printf.

    NVIDIA offers three source level debuggers for CUDA. You may find these more useful than printf for inspecting variables. - Nsight Visual Studio Edition CUDA Debugger - Nsight Eclipse Edition CUDA Debugger - cuda-gdb

    0 讨论(0)
提交回复
热议问题