NVIDIA Nsight Python enables profiling of GPU kernels directly within Python processes. The tool requires Nsight Compute version 2026.2.1 or newer, which can be installed via the NVIDIA apt repository. The library must be imported before PyTorch to successfully inject into the CUDA process.

The profiler uses the nsight.annotate context manager to isolate specific code segments for measurement. It provides metrics such as kernel execution time, standard deviation, and confidence intervals. Users can configure the number of runs, with 20 iterations recommended to assess stability and noise.

Profiling results are returned as a DataFrame, allowing for the calculation of performance metrics like TFLOP/s. The tool supports advanced configurations, including cache flushing and GPU clock locking, which significantly impact measurement accuracy for different input sizes.

The library handles complex scenarios, such as cuBLAS splitting operations into multiple kernels, by combining metrics. It also supports derived metrics and normalization against baseline operations, facilitating comparative analysis across different precision levels like fp32 and fp16.