Profile a program with nsys profile --trace=cuda,nvtx
Record a CUDA timeline with nsys profile --trace=cuda,nvtx in Nsight Systems 2024 and print per-kernel totals from the report without opening the GUI.
This is how you get a timeline of every kernel launch, memcpy and NVTX range from a CUDA program without touching its source. Nsight Systems 2024.5, which ships with CUDA Toolkit 12.6, launches the program under the profiler and writes one report file.
nsys profile --trace=cuda,nvtx --output=vecadd --force-overwrite=true ./vecadd
nsys stats --report cuda_gpu_kern_sum vecadd.nsys-repGenerating '/tmp/nsys-report-vecadd.qdstrm'
Generated:
/home/dev/vecadd.nsys-rep--trace is a comma-separated list of APIs to record, so cuda,nvtx captures the CUDA runtime and driver calls plus any nvtxRangePush ranges, and leaves out OS runtime and OpenGL tracing that would only make the file larger. The .nsys-rep file opens in the Nsight Systems GUI, but nsys stats reads it on the command line and prints tables such as cuda_gpu_kern_sum (time per kernel) and cuda_gpu_mem_time_sum (time per copy direction). That is the fast way to see whether the GPU is busy or waiting on the host before you reach for a per-kernel profiler.
One limit: nsys shows when things ran, not why a kernel is slow. It carries no hardware counters, so answers such as achieved occupancy or memory throughput come from Nsight Compute, not from this report.