NVIDIA Visual Profiler on Windows

I have write a monte carlo implementation on Microsoft Visual Studio Community 2019 with cuda_11.2.0_460.89_win10, on windows 10 20H2 (19042.804).
The program build and run without problem.
Additional i got all my data in csv file.
I’m trying to run visual profiler.

I found that i must run the following command for it:
nvprof -o montecarlocuda.nvvp montecarlocuda.exe
nvprof --analysis-metrics -o montecarlocuda-analysis.nvvp montecarlocuda.exe

The first command run it correctly and create the specific nvvp file without any error.

The second command give me the error:
==5672== Error: Internal profiling error 3938:999.
CUDA error 999 unknown error in line 265
======== Error: CUDA profiling error.

The line 265 of my code is:
cudaCheck (cudaGetLastError ());
and it’s bellow my kernel call.

  1. Is this method, for profiler use, correct?
  2. What is this error and how could resolve it?
  3. Could i have the profiler commands integrated in visual studio when i build a solution?

Thanks to all.

This issue was discussed as part of the post CUPTI error not compatible