how can i debuging a progrem runs on gpu?

There are multiple ways to debug in CUDA.

  1. run your application with cuda-memcheck.

  2. check the return status of CUDA API.

  3. you could also print out the variables in cuda kernel to see the values. e.g.

#include <stdio.h>
#include <assert.h>
#include <cuda.h>
#include <cuda_runtime.h>

__global__ void test(){
    printf("Hi Cuda World");

int main( int argc, char** argv )
    return 0;

There are debuggers available.

On linux you can use cuda-gdb or the debugger personality built into nsight eclipse edition (both are part of the CUDA toolkit)

On Windows, the nsight visual studio edition plug in for MS VS provides device code debugging support.