# Visual Studio looking for stub.c file to debug cuda kernel

**URL:** <https://forums.developer.nvidia.com/t/visual-studio-looking-for-stub-c-file-to-debug-cuda-kernel/237766>\
**Category:** Nsight Visual Studio Edition\
**Created:** [December 22, 2022, 2:16pm UTC](https://forums.developer.nvidia.com/t/visual-studio-looking-for-stub-c-file-to-debug-cuda-kernel/237766 "2022-12-22T14:16:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahmood.nt](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mahmood.nt](https://forums.developer.nvidia.com/u/mahmood.nt)\
**Post date:** [December 22, 2022, 2:16pm UTC](https://forums.developer.nvidia.com/t/visual-studio-looking-for-stub-c-file-to-debug-cuda-kernel/237766/1 "2022-12-22T14:16:38Z")

</div>

Using visual studio 2022 and cuda-12, when I want to step-in to the kernel for debugging, I see an “open dialog” window is open looking for a file called `foo.stub.c`. There is no such file in the project folder and I am wondering how that file is created.

 ![zCdet](https://global.discourse-cdn.com/nvidia/original/3X/6/8/682376402ea10044e860247cf1a5920cd617938d.png)

The complete code is shown below

```
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#define checkCudaErrors(call) \
  do { \
    cudaError_t err = call; \
    if (err != cudaSuccess) { \
      printf("CUDA error at %s %d: %s\n", __FILE__ , __LINE__ , \
             cudaGetErrorString(err)); \
      exit(EXIT_FAILURE); \
    } \
  } while (0)
void print(int* a, int N)
{
    for (int i = 0; i < N; i++)
        std::cout << a[i] << " ";
    std::cout << "\n";
}

__global__ void increment(int* a, int N)
{
    int i = threadIdx.x;
    if (i < N)
        a[i] = a[i] + 1;
}

int main(int argc, char* argv[])
{
    int M = 1;
    int N = 64;
    int *h_a = new int[N];
    for (int i = 0; i < N; i++)
        h_a[i] = i;
    print( h_a, N );

    int* d_a;
    cudaMalloc((void**)&d_a, N * sizeof(int));
    cudaMemcpy(d_a, h_a, N * sizeof(int), cudaMemcpyHostToDevice);

    dim3 grid_size(M); dim3 block_size(N);
    increment <<< grid_size, block_size >>> (d_a, N);
    checkCudaErrors(cudaPeekAtLastError());
    checkCudaErrors(cudaDeviceSynchronize());
    cudaMemcpy(h_a, d_a, N * sizeof(int), cudaMemcpyDeviceToHost);
    print( h_a, N );

    cudaFree(d_a);
    return 0;
}

```

I didn’t find information about stub.c file on the web. Any thoughts on that?

---

<div class="post-metadata">

**Author:** ![Elton](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/elton/32/14043_2.png) [@Elton](https://forums.developer.nvidia.com/u/Elton)\
**Post date:** [January 11, 2023, 9:24pm UTC](https://forums.developer.nvidia.com/t/visual-studio-looking-for-stub-c-file-to-debug-cuda-kernel/237766/2 "2023-01-11T21:24:27Z")

</div>

I tried your code in a simple project and did not see this behavior, I am wondering if it could be something in your project settings. Can you attach the .vcxproj file for the project that reproduces this?

---

<div class="post-metadata">

**Author:** ![yemgard](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@yemgard](https://forums.developer.nvidia.com/u/yemgard)\
**Post date:** [March 14, 2023, 8:29am UTC](https://forums.developer.nvidia.com/t/visual-studio-looking-for-stub-c-file-to-debug-cuda-kernel/237766/3 "2023-03-14T08:29:37Z")

</div>

> [@mahmood.nt](#):
>
> stub

I have found the same problem when using visual studio 2022 and cuda11.6,and I don’t know how to solve this problem
