Skip to content

Kernel debugging does not work properly with Nsight Visual Studio Code Edition #50

@real-zhangzhe

Description

@real-zhangzhe

what happened?

When I use the vscode +
Kernel debugging does not work properly with Nsight Visual Studio Code Edition
plugin to debug a .cu file, the breakpoint is not triggered properly when it is set inside a kernel function. It can only be triggered when the breakpoint is set in a non-kernel function position.

environment

  • OS: WSL ubuntu 24.04
  • vscode version: 1.98.2
  • Nsight Visual Studio Code Edition plugin version: 2024.1
  • Device: nvidia RTX 4060
  • Cuda Version: 12.8
  • Driver Version: 572.60
  • my code:
#include <cuda_runtime_api.h>
#include <stdio.h>

__host__ const char *host_hello_world(void) { return "CPU: Hello world!\n"; }

__device__ const char *device_hello_world(void) {
  return "GPU: Hello world!\n";
}

__global__ void hello_world(void) {
  // break point here, not working
  const char *str = device_hello_world();
  printf("%s", str);
}

int main(int argc, char **argv) {
  // break point here, working
  printf("%s", host_hello_world());
  hello_world<<<1, 10>>>();
  cudaDeviceReset();
  return 0;
}
  • .vscode/launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "CUDA Debug",
      "type": "cuda-gdb",
      "request": "launch",
      "program": "${fileDirname}/${fileBasenameNoExtension}",
      "preLaunchTask": "nvcc compile",
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "debuggerPath": "/usr/local/cuda/bin/cuda-gdb",
    }
  ]
}
  • .vscode/task.json
  "version": "2.0.0",
  "tasks": [
    {
      "label": "nvcc compile",
      "type": "shell",
      "command": "nvcc",
      "args": [
        "-g", "-G",
        "-arch=sm_75",  // RTX 4060
        "-D__CUDA_DEBUG__",
        "-Xcompiler", "-rdynamic",
        "-lineinfo",
        "-I${workspaceFolder}/include",
        "${file}",
        "-o", 
        "${fileDirname}/${fileBasenameNoExtension}"
      ],
      "group": "build",
      "problemMatcher": []
    }
  ]
}

I would be grateful if you could help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions