Cannot attach to a CUDA Process if it is launched from another process
I've been struggling for the last two days with Nsight debugger. What I really want is: 1) I have the Windows application A (c#-managed) that starts the Windows application B (C++ native, OpenGL, CUDA) using the Process.Start() method. 2) When process B is launched along with passed parameters from the application A, I want from within the Visual Studio to attach to process B to be able to debug the CUDA code using the nsight debugger. My working configuration is: a) CUDA 8.0 integrated in the VS 2012 b) GeForce Game Ready driver 382.52 c) NVIDIA Nsight Visual Studio Edition, Version 5.2, Build 5.2.0.16321 d) Windows 10 To debug the application I start nsight monitor as administrator (very important). What I could observe until now is that if I start a single CUDA application (e.g. volumeFiltering from the CUDA samples), then I can see it in the "available processes" in the Visual Studio and I can attach to it. But if I start a CUDA application such that application A which is the managed code application starts the application B which is a CUDA application, then I am able to see both applications in the "available processes" with following conditions: - Application A is enabled and is of type CUDA - Application B is disabled and has no type Initially, the application A is not of type CUDA which is definitelly correct. It gets that type assigned as soon as the process B is launched. For the given constellation, someone can give advice on what I can do to get the application B enabled in the "available processes" in Visual Studio in order to attach to it and to debug it?
I've been struggling for the last two days with Nsight debugger. What I really want is:

1) I have the Windows application A (c#-managed) that starts the Windows application B (C++ native, OpenGL, CUDA) using the Process.Start() method.
2) When process B is launched along with passed parameters from the application A, I want from within the Visual Studio to attach to process B to be able to debug the CUDA code using the nsight debugger.


My working configuration is:
a) CUDA 8.0 integrated in the VS 2012
b) GeForce Game Ready driver 382.52
c) NVIDIA Nsight Visual Studio Edition, Version 5.2, Build 5.2.0.16321
d) Windows 10

To debug the application I start nsight monitor as administrator (very important).

What I could observe until now is that if I start a single CUDA application (e.g. volumeFiltering from the CUDA samples), then I can see it in the "available processes" in the Visual Studio and I can attach to it. But if I start a CUDA application such that application A which is the managed code application starts the application B which is a CUDA application, then I am able to see both applications in the "available processes" with following conditions:

- Application A is enabled and is of type CUDA
- Application B is disabled and has no type

Initially, the application A is not of type CUDA which is definitelly correct. It gets that type assigned as soon as the process B is launched.


For the given constellation, someone can give advice on what I can do to get the application B enabled in the "available processes" in Visual Studio in order to attach to it and to debug it?

#1
Posted 06/24/2017 10:34 AM   
Hi, I think you can attach the process B. 1. Please make sure that process A is launched with administrator privileges, then the process B also has admi privileges, this is important on win10. 2. Please make sure that process A is launched with env NSIGHT_CUDA_DEBUGGER=1, then the process B also has NSIGHT_CUDA_DEBUGGER=1. 3. Then you can find the process B in available processes. PS: I think you can also launch process B with this env via Process.Start(). Best Regards Harry
Hi,

I think you can attach the process B.

1. Please make sure that process A is launched with administrator privileges, then the process B also has admi privileges, this is important on win10.
2. Please make sure that process A is launched with env NSIGHT_CUDA_DEBUGGER=1, then the process B also has NSIGHT_CUDA_DEBUGGER=1.
3. Then you can find the process B in available processes.

PS: I think you can also launch process B with this env via Process.Start().

Best Regards
Harry

#2
Posted 06/26/2017 02:47 AM   
Hi Harry, thanks for your reply. Just to clarify one thing - I do see the process B in available processes, but it is grayed out, it is disabled. I did the follwoing according to your suggestion: 1. I've started the process A as administrator 2. NSIGHT_CUDA_DEBUGGER is set to 1. I've set that value in the Windows Environment Variables. I've added a new User- and a new System-variable 3. I can find the process B in available processes, but it is disabled. Do you think, I should set the NSIGHT_CUDA_DEBUGGER in the code? If yes, how do I do that? Best Regards, dxUser P.S. The odd thing is that initailly the Process A is disabled in available processes. It gets enabled and it gets the CUDA-type assigned, as soon as the process B was launched. But the process A is a pure .NET application.
Hi Harry,
thanks for your reply. Just to clarify one thing - I do see the process B in available processes, but it is grayed out, it is disabled. I did the follwoing according to your suggestion:

1. I've started the process A as administrator
2. NSIGHT_CUDA_DEBUGGER is set to 1. I've set that value in the Windows Environment Variables. I've added a new User- and a new System-variable
3. I can find the process B in available processes, but it is disabled.

Do you think, I should set the NSIGHT_CUDA_DEBUGGER in the code? If yes, how do I do that?

Best Regards,
dxUser

P.S. The odd thing is that initailly the Process A is disabled in available processes. It gets enabled and it gets the CUDA-type assigned, as soon as the process B was launched. But the process A is a pure .NET application.

#3
Posted 06/26/2017 08:32 AM   
I have no more suggestions, could you please give me your project if it's not confidential, I shall try to repo it on my computer.
I have no more suggestions, could you please give me your project if it's not confidential, I shall try to repo it on my computer.

#4
Posted 06/27/2017 03:01 AM   
In order to provide you a minimal code, I've implemented a WPF-ApplicationA with just a command button that triggers the launch of the volumeFiltering.exe from the CUDA Samples. [code] private void runCudaApplication(string exeName) { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = exeName; IntPtr handle = Process.Start(startInfo).MainWindowHandle; } [/code] Doing so, I can see the volumeFiltering.exe in available processes in VS. Therefore, I'll need to examine my real implementation and to isolate the portion that prevents me to see my application as desired. When I find something I'll let you know. Thanks for your willingness to help!
In order to provide you a minimal code, I've implemented a WPF-ApplicationA with just a command button that triggers the launch of the volumeFiltering.exe from the CUDA Samples.

private void runCudaApplication(string exeName)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = exeName;
IntPtr handle = Process.Start(startInfo).MainWindowHandle;
}

Doing so, I can see the volumeFiltering.exe in available processes in VS.
Therefore, I'll need to examine my real implementation and to isolate the portion that prevents me to see my application as desired. When I find something I'll let you know.

Thanks for your willingness to help!

#5
Posted 06/27/2017 09:01 AM   
Maybe some of your codes clear the environment variable, please make sure that your target app has NSIGHT_CUDA_DEBUGGER=1
Maybe some of your codes clear the environment variable, please make sure that your target app has NSIGHT_CUDA_DEBUGGER=1

#6
Posted 06/28/2017 08:54 AM   
To ensure there is no impact from my site, I've taken the volumeFiltering project from the CUDA Samples. Nsight monitor is running. 1.a) Build the project for the debug configuration and Win32 platform 1.b) Run the volumeFiltering.exe from the Windows Explorer 1.c) Open available processes in VS 1.d) volumeFiltering.exe is visible but disabled 2.a) change the Active solution platfrom from Win32 --> x64 and rebuild 2.b) Run the volumeFiltering.exe from the Windows Explorer 2.c) Open available processes in VS 2.d) volumeFiltering.exe is visible and [b]enabled[/b] Actually, I would have expected there is no difference whether the application targets the Win32 or x64. However, that seems to be the fix in general. I'll need to rebuilt my project for the x64 which will not be a quick fix. Thanks and best regards.
To ensure there is no impact from my site, I've taken the volumeFiltering project from the CUDA Samples.

Nsight monitor is running.

1.a) Build the project for the debug configuration and Win32 platform
1.b) Run the volumeFiltering.exe from the Windows Explorer
1.c) Open available processes in VS
1.d) volumeFiltering.exe is visible but disabled

2.a) change the Active solution platfrom from Win32 --> x64 and rebuild
2.b) Run the volumeFiltering.exe from the Windows Explorer
2.c) Open available processes in VS
2.d) volumeFiltering.exe is visible and enabled

Actually, I would have expected there is no difference whether the application targets the Win32 or x64. However, that seems to be the fix in general. I'll need to rebuilt my project for the x64 which will not be a quick fix.

Thanks and best regards.

#7
Posted 06/28/2017 12:04 PM   
Yeah, that's right, nsight cannot attach the x84 process, we have a bug to track it but I guess it won't be implemented in the future, cuda 9.0 won't support x84 anymore.
Yeah, that's right, nsight cannot attach the x84 process, we have a bug to track it but I guess it won't be implemented in the future, cuda 9.0 won't support x84 anymore.

#8
Posted 06/29/2017 05:57 AM   
All those tricky things make development so hard. I spent hours and hours to fix something that is just the matter of correct settings. e.g. it is required to run the application as Admin, only x64 applications are supported etc. Probably, I should blame myself because I have not read the documentation studiosly. However, could you point to that Nsight document where I could find such instructions in order to avoid such surprises in the future. Many thanks and best regards.
All those tricky things make development so hard. I spent hours and hours to fix something that is just the matter of correct settings. e.g. it is required to run the application as Admin, only x64 applications are supported etc.

Probably, I should blame myself because I have not read the documentation studiosly. However, could you point to that Nsight document where I could find such instructions in order to avoid such surprises in the future.

Many thanks and best regards.

#9
Posted 06/29/2017 09:02 AM   
The doc doesn't explain the administrator privileges and x86 issues. Actually win10 needs administrator privileges to attach a process but win7 doesn't need it. I will raise bug to update the doc.
The doc doesn't explain the administrator privileges and x86 issues.

Actually win10 needs administrator privileges to attach a process but win7 doesn't need it.

I will raise bug to update the doc.

#10
Posted 06/29/2017 09:09 AM   
That's O.K. with me. Thanks! P.S. and what about nsgiht can attach only to a x64 Process? In my humble opinion, If it is not documented, it should be. best regards.
That's O.K. with me. Thanks!

P.S. and what about nsgiht can attach only to a x64 Process? In my humble opinion, If it is not documented, it should be.

best regards.

#11
Posted 06/29/2017 09:25 AM   
Nope, it cannot attach x84 process, I submitted this bug about 1 year ago and no one handle it until now, as cuda 9.0 will only support x64, I guess they will completely remove the x86 support in the future.
Nope, it cannot attach x84 process, I submitted this bug about 1 year ago and no one handle it until now, as cuda 9.0 will only support x64, I guess they will completely remove the x86 support in the future.

#12
Posted 06/29/2017 09:31 AM   
Scroll To Top

Add Reply