How to Use Nsight Compute: Test CUDA Kernel Bottleneck Hypotheses with Metrics
Nsight Compute is NVIDIA’s kernel profiler for investigating which GPU resource keeps an individual CUDA kernel from finishing as quickly as expected. Start by selecting a kernel that matters on the Nsight Systems timeline, then use compute-pipeline, memory-hierarchy, and scheduler metrics to test a specific bottleneck hypothesis. Do not diagnose a cause from one metric alone: narrow the collection first and verify the effect of a change in an unprofiled run.
How to Use Nsight Compute: Test CUDA Kernel Bottleneck Hypotheses with Metrics
Nsight Compute is NVIDIA’s kernel profiler for investigating which GPU resource keeps an individual CUDA kernel from finishing as quickly as expected. Start by selecting a kernel that matters on the Nsight Systems timeline, then use compute-pipeline, memory-hierarchy, and scheduler metrics to test a specific bottleneck hypothesis. Do not diagnose a cause from one metric alone: narrow the collection first and verify the effect of a change in an unprofiled run.
What question does Nsight Compute answer?
Nsight Compute (NCU) collects hardware performance counters, source-correlated information, device properties, and other details for individual CUDA kernel executions, then organizes them into a report. It can help answer which compute pipeline or memory path is busy, whether the warp schedulers have work ready to issue, and whether memory accesses are wasting bandwidth. Available counters and report sections depend on the GPU architecture and installed Nsight Compute release, so do not assume that a metric copied from an older article exists on the current device. NVIDIA Nsight Compute User Guide
NCU does not explain an application-wide CPU/GPU timeline. First use Nsight Systems to find kernels or ranges that materially contribute to response time, then choose an execution worth optimizing. Nsight Systems documents a handoff from a kernel on its timeline to Nsight Compute. If a kernel contributes little to total latency, improving its internal efficiency may barely change application response time. NVIDIA Nsight Systems User Guide
Collect a report for one kernel in a representative run
Before profiling, record representative inputs, arguments, the build, and the GPU. Check whether kernel names or launch order change across repeated calls, and whether another process is using the device. If access to performance counters is blocked, NCU may report ERR_NVGPUCTRPERM. Check the organization’s driver policy or non-admin counter settings. Running the application as an administrator is not automatically required to diagnose the issue. NVIDIA Compute Triage Guide
The following is an example for a Linux shell. Replace myKernel, ./app, and the input file with the names and arguments of the actual program.
ncu --set basic --kernel-name myKernel --launch-count 1 -o baseline ./app --input sample.binThe basic set is the default report set. With the default matching basis, --kernel-name selects a kernel whose function name matches exactly, and --launch-count 1 profiles only one launch matching that filter. The -o option saves the report to a file. If the kernel does not appear, first inspect its actual name in the application; for template names or multiple variants, use the regular-expression filter documented in the CLI guide. Narrowing the profiled kernels reduces unnecessary counter collection even when the full application still runs. Use --list-sets and --list-sections to inspect the collection sets and sections available in the installed version. NVIDIA Nsight Compute CLI Guide
Connect metrics to a hypothesis and a next check
Start with GPU Speed of Light for the broad picture of compute and memory throughput. Then inspect Memory Workload Analysis for DRAM, L2, L1, and access efficiency, and Compute Workload Analysis or Scheduler Statistics for pipelines and execution stalls. A percentage in the report compares a selected unit with its peak throughput; a high value alone does not prove that unit is the cause. Check whether the workload, the memory path required by the algorithm, and the active pipeline agree. NVIDIA’s triage guide also connects each observation with follow-up metrics and decision branches to narrow a cause. NVIDIA Compute Triage Guide
| Report signal | What to check next | What the signal alone does not establish |
|---|---|---|
| High DRAM throughput | Bytes transferred, L2 throughput and hit rate, and data reuse in the algorithm | That memory access is efficient or has no room to improve |
| High throughput in a specific compute pipeline | Whether source/SASS shows many such instructions, and whether precision and pipeline are intended | That the entire GPU has reached its compute limit |
| Low occupancy | Register and shared-memory use, active and eligible warps, and stall causes | That raising occupancy will necessarily make the kernel faster |
| Many memory sectors per request or shared-memory wavefronts | Address layout, alignment, coalescing, and shared-memory bank conflicts | That the same ratio has the same meaning in L1 and L2 tables |
| An n/a value or a path that contradicts expectations | Whether the GPU generation supports the metric and the selected section and kernel are correct | That zero or n/a means no performance |
For a hypothetical example, suppose an image-normalization kernel stands out in the profiler. If you expect each thread to read consecutive pixels but see more sectors per request than expected, inspect address stride, array layout, element size, and the accesses within a warp alongside the code. Change layout or indexing only if the evidence supports that memory-access hypothesis. The table’s metrics are clues for investigation, not results showing that a particular optimization already worked.
Interpret Roofline and occupancy under the right conditions
Roofline compares a kernel’s arithmetic intensity (operations divided by bytes moved from memory) and achieved throughput with compute and memory-bandwidth ceilings. A point near a ceiling is a reason to investigate that resource as a possible limiter. The selected Roofline section must match the actual instruction path. Comparing Tensor Core work with a general floating-point ceiling, or trusting a chart when the executed FLOP count is wrong, can lead to a false conclusion. Cross-check source or SASS, operation counters, and SM frequency; select the Roofline section for the relevant precision or Tensor path when needed. NVIDIA Nsight Compute Profiling Guide
Occupancy is the active warps on one SM as a fraction of the maximum number of warps it could support. Low occupancy can leave too few warps to hide memory latency, but high occupancy is not itself a performance target. Aggressively reducing register use can increase spilling and create more memory traffic. Check the occupancy calculator and register/shared-memory use, then use Scheduler Statistics to see whether too few warps were actually eligible to run. Do not optimize a metric that is unrelated to the suspected cause.
Why replay and profiler time can change the result
Not every counter can be collected during one kernel execution. Kernel replay saves accessible memory on the first pass and restores the part written by the kernel before later passes, so each measurement sees the same input state. The cost of saving and restoring grows with the data accessed, especially data written. Application replay runs the entire application again instead of repeating only the kernel, so execution must be deterministic across passes and CPU work such as startup or file reads is repeated. Application replay may be more appropriate when the program prepares its own cache state or a kernel depends on host responses. NVIDIA Nsight Compute Profiling Guide
NCU can flush caches between replay passes, adjust SM clocks by default, and serialize kernel execution for measurement. These behaviors can improve metric reproducibility but differ from real application concurrency or a warm-cache state. Nsight Compute and Nsight Systems also measure kernel duration differently, so assume neither that their durations will match nor that a host timer or CUDA event under the profiler represents the tool-free runtime; profiler overhead can be included in those timers. Do not use the report duration as a substitute for user-visible end-to-end response time. NVIDIA Nsight Compute Profiling Guide
Verify a change in five steps
**Fix the question and baseline.** Use Nsight Systems to select a kernel that matters to total response time. Record the input, GPU, build, arguments, and an unprofiled baseline time. First ask whether optimizing this individual kernel is worthwhile.
**Collect one target with the basic set.** Filter by function name and limit the number of launches. If the kernel is not selected, check its name, invocation order, and filters. Treat counter-permission errors as driver or execution-policy problems, not as performance measurements.
**Choose one hypothesis that explains the observation.** Examples include saturated DRAM bandwidth, a saturated compute pipeline, insufficient latency hiding, or inefficient access. Do not conclude from occupancy or one Speed of Light percentage alone.
**Add only sections that can test or disprove the hypothesis.** For a memory hypothesis, inspect actual traffic paths in Memory Workload Analysis; for compute, inspect Compute Workload Analysis and instruction mix. Check for unsupported metrics, work that is too short or variable, and differences between replay passes. Reduce the metric set or measure more representative work when needed.
**Change one factor and measure again with the same settings.** Keep inputs, kernel selection, replay, and cache settings consistent when comparing reports. Confirm that the metrics moved as predicted, then run the application several times without the profiler and check end-to-end response time. If it did not improve, revert the change and test another hypothesis.
The outcome should not be merely “occupancy increased.” It should be evidence that supports or rejects a hypothesis and a check of whether the actual program became faster. An NCU report is evidence for that decision; final performance must be measured in a normal run close to deployment conditions.
References
[NVIDIA Nsight Compute User Guide](https://docs.nvidia.com/nsight-compute/NsightCompute/)
[NVIDIA Nsight Compute Profiling Guide](https://docs.nvidia.com/nsight-compute/ProfilingGuide/)
[NVIDIA Nsight Compute CLI Guide](https://docs.nvidia.com/nsight-compute/NsightComputeCli/)
[NVIDIA Compute Triage Guide](https://docs.nvidia.com/nsight-compute/ComputeTriage/)
[NVIDIA Nsight Systems User Guide](https://docs.nvidia.com/nsight-systems/UserGuide/index.html)