visual-studio 如何使用 Visual Studio 2008 调试到 CUDA 内核代码中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4040383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:39:51  来源:igfitidea点击:

How to debug into CUDA kernel code using visual studio 2008?

visual-studiodebuggingcuda

提问by ntsue

Hey, I am using Visual Studio 2008, with CUDA 3.2. I am trying to debug into a function with this signature:

嘿,我使用的是带有 CUDA 3.2 的 Visual Studio 2008。我正在尝试调试具有此签名的函数:

 MatrixMultiplication_Kernel<<<dimGrid, dimBlock>>>(Md, Nd, Pd, Width);

I can step into the function, however when I get into the function it doesn't let me step over any of the code and tells me that no source is available. Anybody knows how to debug into this properly?

我可以进入该函数,但是当我进入该函数时,它不会让我跳过任何代码并告诉我没有可用的源代码。有人知道如何正确调试吗?

Thank you!

谢谢!

采纳答案by Tom

Update:Parallel Nsight is now free and supports debugging with only one GPU in your system.

更新:Parallel Nsight 现在是免费的,并且支持在您的系统中仅使用一个 GPU 进行调试。

To debug device code within Visual Studio you will need Parallel Nsight. The standard version is freeand offers the debugging you require as well as device code profiling.

要在 Visual Studio 中调试设备代码,您将需要Parallel Nsight。标准版本是免费的,并提供您需要的调试以及设备代码分析。

If you want to debug on a single machine then you will need two GPUs (since the GPU running the code will be stopped when it hits a breakpoint, and hence your display would block as well). They don't need to be high-end GPUs though, anything from G92 onwards will do (including most Fermi GPUs as listed here).

如果您想在一台机器上调试,那么您将需要两个 GPU(因为运行代码的 GPU 将在遇到断点时停止,因此您的显示也会阻塞)。不过,它们不需要是高端 GPU,从 G92 开始的任何东西都可以(包括此处列出的大多数 Fermi GPU )。

回答by JSoet

You can now debug on a single machine with only one GPU using NSight.

您现在可以使用NSight在只有一个 GPU 的单台机器上进行调试

Thought I'd update this, since the previous answers are no longer correct (you no longer need 2 GPUs) and it sent me off in the wrong direction for a while.

我想我会更新这个,因为以前的答案不再正确(你不再需要 2 个 GPU)并且它让我在错误的方向上走了一段时间。

回答by mch

Are you using Nsight? Vanilla Visual Studio cannot step into device code, but with Nsight, this is possible. Unfortunately, limitations of the Windows device driver model mean there are some serious restrictions. It used to be that two machines were required to do the debugging. The target machine would run the CUDA code on it's GPU, and had to be using the TCC driver. The host machine would run Visual Studio and control the target. It seems that it is now possible to debug CUDA code on the same machine as long as you have two GPU's, one for compute and one for display. There are a number of other problems mentioned in the user guide.

你在使用Nsight吗?Vanilla Visual Studio 无法进入设备代码,但使用 Nsight,这是可能的。不幸的是,Windows 设备驱动程序模型的局限性意味着存在一些严重的限制。以前调试需要两台机器。目标机器将在其 GPU 上运行 CUDA 代码,并且必须使用 TCC 驱动程序。主机将运行 Visual Studio 并控制目标。似乎现在可以在同一台机器上调试 CUDA 代码,只要您有两个 GPU,一个用于计算,一个用于显示。用户指南中还提到了许多其他问题。

This may not be an acceptable answer, but: If you can compile your code on Linux, you can use cuda-gdb to debug kernels. cuda-gdb is part of the Linux CUDA toolkit.

这可能不是一个可接受的答案,但是:如果您可以在 Linux 上编译代码,则可以使用 cuda-gdb 来调试内核。cuda-gdb 是 Linux CUDA 工具包的一部分。

回答by Eugene Smith

You can't debug CUDA kernel code using visual studio. Visual studio can only debug programs that run on the CPU.

您无法使用 Visual Studio 调试 CUDA 内核代码。Visual Studio 只能调试在 CPU 上运行的程序。

In fact, I don't think that you can debug CUDA kernel code in Windows at all any more. CUDA used to have a host emulation mode, but that was removed in 3.0. The only debugging tools available are cuda-gdb and ocelot, and, as far as I know, neither of them supports Windows.

事实上,我认为您再也无法在 Windows 中调试 CUDA 内核代码了。CUDA 曾经有一个主机仿真模式,但在 3.0 中被删除了。唯一可用的调试工具是 cuda-gdb 和 ocelot,据我所知,它们都不支持 Windows。