Challenges in Profiling CUDA Programs with Nsight Systems

I am trying to profile a CUDA program that involves processing a large dataset with numerous CUDA API host calls. When I attempt to profile the program using Nsight Systems, I notice that the profiler does not provide an accurate representation of the program flow, as the NVTX markers are misplaced. Additionally, instead of displaying the CUDA API calls, it merely shows CUDA profiling memory allocations.

Can you give me the exact command that you are using?

What version of Nsys are you using and on what OS?

@liuyis once we have that info, can you help?

Yes. Here is the command that I am using:
set CUDA_VISIBLE_DEVICES=0,1 && “C:\Program Files\NVIDIA Corporation\Nsight Systems 2026.1.1\target-windows-x64\nsys.exe” profile --output=D:\nsight-profiles\half.nsys-rep --force-overwrite=true --stats=true “C:\build\test.exe”

I am using version 2026.1.1 on Windows 11.

Is it possible to share the report file?

Could you clarify with “NVTX markers are misplaced”? How was that observed?

I tried to place markers around certain CUDA calls. These markers are shown in the profile. However, I could not identify the corresponding CUDA API calls, and there is no trace of the corresponding execution on the GPU. Instead of showing CUDA API host calls, the profile displays CUDA memory profiling allocations, as shown in the figure. The issue might not be with the NVTX markers but rather the inability to track CUDA API calls.

Please find the log file.

nsys-ui.log (48.1 MB)

Thanks for sharing. Yes, I think the issue is more on CUDA trace side, the CUDA API calls are probably missing.

Did the target app exit gracefully? One typical reason why this could happen is that if the app was forcibly killed, the buffers holding CUDA trace data will not have a chance to be flushed, and events can be lost.

Yes, I am experiencing the aforementioned behavior even when the application runs without errors. Is there an upper limit on the number of CUDA API calls beyond which we cannot track them?

Is there an upper limit on the number of CUDA API calls beyond which we cannot track them?

How long is your profiling session? If it is not too long (less than 5 minutes), there should not be a limitation.

Yes, I am experiencing the aforementioned behavior even when the application runs without errors.

Could you collect logs from Nsys injection library for us to look into?

Steps:

  1. Create the folder c:\nvlog
  2. Save the following to c:\nvlog\nvlog.config
    • + 100iwef   global
      $ c:\nvlog\nsight-sys-${proc}-${pid}.log
      ForceFlush
      Format $sevc$time|${name:0}|PID${pid:0}|TID${tid:0}|${file:0}:${line:0}[${sfunc:0}]:$text
      
  3. Run Nsys with an additional CLI option --env-var=NVLOG_CONFIG_FILE=c:\nvlog\nvlog.config, e.g.
    • set CUDA_VISIBLE_DEVICES=0,1 && “C:\Program Files\NVIDIA Corporation\Nsight Systems 2026.1.1\target-windows-x64\nsys.exe” profile --output=D:\nsight-profiles\half.nsys-rep --force-overwrite=true --stats=true --env-var=NVLOG_CONFIG_FILE=c:\nvlog\nvlog.config “C:\build\test.exe”
      
  4. After the collection, there should be log file(s) exist in c:\nvlog\. Zip the whole directory and share back with us.

Thanks

Please find the attached log files.
The application takes around 100 seconds to finish.

nvlog.zip (6.4 MB)

How can we profile programs that run for more than 5 minutes?

If you need to profile for longer, you probably can, depending on how many kernels are in your code and how many features you turn on.

You can also delay the start or set a duration or turn the profiling on/off with cudaProfilerStart/Stop or NVTX ranges.