Table of Contents
Shortcuts

# Event

class torch.cuda.Event(enable_timing=False, blocking=False, interprocess=False)

  Wrapper around a CUDA event.

  CUDA events are synchronization markers that can be used to monitor the device’s progress, to accurately measure timing, and to synchronize CUDA streams.

  The underlying CUDA events are lazily initialized when the event is first recorded or exported to another process. After creation, only streams on the same device may record the event. However, streams on any device can wait on the event.

  Parameters:

    - enable_timing (bool, optional) – indicates if the event should measure time (default: `False`)

    - blocking (bool, optional) – if `True`, `wait()` will be blocking (default: `False`)

    - interprocess (bool) – if `True`, the event can be shared between processes (default: `False`)

  elapsed_time(end_event)

    Returns the time elapsed in milliseconds after the event was recorded and before the end_event was recorded.

  classmethod from_ipc_handle(device, handle)

    Reconstruct an event from an IPC handle on the given device.

  ipc_handle()

    Returns an IPC handle of this event. If not recorded yet, the event will use the current device.

  query()

    Checks if all work currently captured by event has completed.

    Returns:

      A boolean indicating if all work currently captured by event has completed.

  record(stream=None)

    Records the event in a given stream.

    Uses `torch.cuda.current_stream()` if no stream is specified. The stream’s device must match the event’s device.

  synchronize()

    Waits for the event to complete.

    Waits until the completion of all work currently captured in this event. This prevents the CPU thread from proceeding until the event completes.

    > Note

    > This is a wrapper around `cudaEventSynchronize()`: see CUDA Event documentation for more info.

  wait(stream=None)

    Makes all future work submitted to the given stream wait for this event.

    Use `torch.cuda.current_stream()` if no stream is specified.

    Note

    This is a wrapper around `cudaStreamWaitEvent()`: see CUDA Event documentation for more info.

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.