warp.ScopedCudaProfiler#

class warp.ScopedCudaProfiler(device=None)[source]#

Context manager for limiting an external CUDA profiler’s capture range.

Calls cuda_profiler_start() on entry and cuda_profiler_stop() on exit. The device is resolved during construction, and the same CUDA context is used when profiling starts and stops even if the current device changes inside the block.

The attached profiler and its configuration determine which activity is collected, including CUDA API calls, allocations, transfers, kernels, and synchronization.

Parameters:

device (DeviceLike) – Device whose CUDA context profiling is controlled for.

Example

with warp.ScopedCudaProfiler():
    run_workload()