debugging CUDA code - c++

i am using Nsight along with VS 2008 to debug my cuda code.
I have 2 Geforce GTX 460 SE cards in my computer.
i read Nsight's user guide and updated Nvidia Control panel as stated in the guide.
but i still have a problem. in my code when i set cudaSetDevice(0); i get an error in nsight stating that i cannot debug since the device is attached to a monitor, which is true.
but when i set cudaSetDevice(1); and start cuda debugging, nsight gives no errors, but the program does not break at the breakpoint that i put in the code!.
does anybody know whats wrong?

Set the -G0 flag in the CUDA Build Rule to enable debug information in the compiled code. Your breakpoint should be hit after that.
(Reply contributed originally by Jawad Masood, so I have made the reply Community Wiki.)

Related

Why do profilers fail to get information from my program?

I am trying to profile a C++ program but whenever I run a profiler I get no information even though the debug information works as I can run a debugger on it.
I tried using AMD uProf, Very Sleepy and Visual Studio but all of them give me no information. No functions get detected.
The program is compiled using clang-cl and runs for only a few milliseconds.
It seems like Windows Defender was messing with somethings, it has caused me some trouble in the past as well. Disabling it and rebooting seems to have fixed the problem. Also due to the program having such a short execution time most profilers aren't able to get enough samples

NVidia NSight "process creation failure"

When launching my game from NVidia NSight, I get the following error message:
Preparing to launch...
Launch failure: Process creation failure
Launch failed.
The game launches just fine, but with no way to attach to it, I can't do frame debugging or anything else. There is no other error message or information that is logged. This is on Arch Linux.
This is probably not the answer you were hoping for, but after running into the same problem, I sent a bug report to Nvidia (https://developer.nvidia.com/rdp/bugs/nsight-graphics-bug-reporting) and I was told that Arch isn't supported at the moment (see https://developer.nvidia.com/nsight-graphics-requirements).
It's possible that, if there is enough demand, support could be added. So feel free to send them some feedback/request as well.
As an alternative, for debugging, RenderDoc works well enough on Arch, but it's not very good for profiling.
FYI, Arch Linux has now been officially supported by Nsight Graphics.
Ubuntu 18.04, 20.04
RHEL 7.6
Centos 7.6
Arch Linux 2021.05.01
https://developer.nvidia.com/nsight-graphics-requirements

Advanced hotspots analysis by Intel Vtune Amplifier XE2016 of a VS2015 console application not working

When executing the Intel "Advanced Hotspots, stacks and context switches analysis" (or higher) of my simple (a few lines) VS2015 console C++ (native) application, its processing hangs and Windows restart is needed, see the sample solution and screen captures enclosed in the zip file). The same applies for larger solutions... ". The "Basic Hotspots" and "Advanced Hotspots without stacks..." works fine.
Can anybody help?
The solution and screen captures of the hotspots settings:
https://app.box.com/s/ihb51o9cxrn8y7li6eupa9o7qbkof4dp
Windows 10Pro 64bit Build 1607, Intel Core I7-4771
VS2015 Community V. 14.0.25431.01 Updt. 3
Intel VTume Ampl. XE2016 Updt 2, build 444464
Thanks for help!!!!
This issue should be fixed in the VTune Amplifier 2017 XE.

How to debug host code in mixed cuda C++ program?

My work platforms are VS2010 and Nsight 3.1.
With Nsight, breakpoints can be set in cuda kernel and the debugger works well. If the breakpoints are set in host code, Nsight just ignores them.
I don't know if it is possible to set breakpoints in host code and use the debugger provided by VS2010. I tried, but the program stops when it meets the first cudaMalloc function. Could someone please tell me how to debug host code in a mixed cuda and c++ program?
Thanks a lot.
I'm afraid you could not debug both CUDA and c++ program in on VS. Here is a workaround. Hope it could help you
Launch a Windows command line. Set NSIGHT_CUDA_DEBUGGER=1
In this command line, execute your CUDA application (Here I suppose it's a long-term execution).
Open a VS. Tools menu ->Attach to Process. Choose transport as Nsight CPU Debugger and attach to your application. Then you could debug CUDA code
Open another VS. Choose transport as Default. Attach to the application then you could debug C++ code
Please pay attention, if the application is suspended by a VS, it could not be debugged by the other VS. You must resume current one and then switch to the other.

NSight crash at frame profile

I'm using Visual Studio 2012.
Nsight Visual Studio:
Version 3.2.2
Build Number: 3.2.2.13342
My Graphics Card Information:
GeForce GT 720M
Driver version: 33182
Directx 3D version: 11.1
OpenGL 4.4
Each time I try to pause and capture a frame, and then click in Frame Profile, my program crash. This apply for all OpenGL program in my computer. First, I though it could be due to the Operating System, so I installed the OS again, but it still crashes.
This is the stack at the time the program crashes.
Before crash
Crash
I saw a crash error by NSight here, but it seems different from me.
You're best off reporting bugs in Nsight to Nvidia. 3.2.2 is a very new version and chances are it's going to be something someone hasn't reported yet.
https://devtalk.nvidia.com/default/board/84/nsight-visual-studio-edition/
The likely culprits will be using a newer or slightly out-of-the-ordinary OpenGL extension that the tool doesn't support yet. If you want to get to the bottom of it, binary chop parts of your application out until it does capture properly and add them back in until it stops working.