简体   繁体   English

在Visual Studio中调试cuda文件

[英]debugging cuda files in visual studio

i have a cpp function (function.cpp") which i "mex"-ed. then i open the function.cpp file in visual studio and attach visual studio to a running matlab process. 我有一个cpp函数(function.cpp“),我通过“ mex”编辑,然后在Visual Studio中打开function.cpp文件,并将Visual Studio附加到正在运行的matlab进程中。

when i call the function in matlab i am able to set breakpoints in the function.cpp file and step through it observing the variables. 当我在matlab中调用函数时,我可以在function.cpp文件中设置断点,并逐步观察变量。

The debugging process breaks down when i change the function to a cuda file (function.cu). 当我将功能更改为cuda文件(function.cu)时,调试过程中断。 Following the process described above i am still able to stop within function.cu but i cannot see any variables. 按照上述过程,我仍然可以在function.cu内停止,但看不到任何变量。 when i try to "watch" a variable it says "Error symbol .. not found" 当我尝试“观察”变量时,它显示“错误符号..未找到”

i have nsight installed in visual studio. 我在Visual Studio中安装了nsight。 question: how can i observe my variables in the file function.cu in the debug mode as i do for the function.cpp file. 问题:我如何像在function.cpp文件中那样在调试模式下观察我的变量在function.cu文件中。 Is this possible ? 这可能吗 ?

Note that the function.cu is not in a project. 请注意,function.cu不在项目中。 it is just a standalone file with cpp code of a function (say somefunction(){}). 它只是一个带有函数cpp代码的独立文件(例如somefunction(){})。 for debugging purpose i am opening it up in visual studio. 出于调试目的,我在Visual Studio中将其打开。 i am compiling the function.cu file in matlab using "nvmex -g wrapper.cu" the wrapper.cu is a matlab mexfunction wrapper which makes calls to somefunction() written inside function.cu 我正在使用“ nvmex -g wrapper.cu”在matlab中编译function.cu文件。wrapper.cu是一个matlab mexfunction包装器,它调用了写入在function.cu中的somefunction()。

You're using the VS debugger which is a host debugger, so it doesn't know how to debug device programs. 您正在使用VS调试器,它是主机调试器,因此它不知道如何调试设备程序。 To debug device code in Windows you should look at Parallel Nsight Visual Studio Edition . 要在Windows中调试设备代码,应查看Parallel Nsight Visual Studio Edition

You can search the docs for a guide to attaching to a running process, for the current release (2.2) the specific page is here . 您可以在文档中搜索有关附加到正在运行的进程的指南,对于当前版本(2.2),特定页面位于此处

You attached VS in, but stopped in function 'main'. 您在其中附加了VS,但在功能“ main”中停止了。 Looks like you are still hitting the CPU code. 看起来您仍然在点击CPU代码。 When you follow Tom's suggestion to attach the debugger, have you choosed "NVIDIA GPU Debugger" in the Transport dropdown? 当您遵循Tom的建议连接调试器时,是否在“传输”下拉列表中选择了“ NVIDIA GPU调试器”?

To debug any cuda-code you'll need a gpu on which no desktop environment/server is running. 要调试任何cuda代码,您将需要一个不运行桌面环境/服务器的GPU。 For windows that means, that you need a second gpu. 对于Windows,这意味着您需要第二个GPU。 I'm not to 100% sure if it has to be a nvida gpu, too. 我不确定100%是否也必须是nvida gpu。 Than you will be able to bedubg your code. 比您将能够验证您的代码。 Under linux you're able to debug with only one gpu because you can shut down the x-server and debug with cuda-gdb per command line. 在Linux下,您只能使用一个GPU进行调试,因为您可以关闭x服务器并在每个命令行中使用cuda-gdb进行调试。 Further informations will give you the cuda-gdb manual 更多信息将为您提供cuda-gdb手册

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM