synchronize

paddle.cuda. synchronize ( device: DeviceLike = None ) None [source]

Wait for all streams on a given device to complete.

This function blocks the calling thread until all the operations on the specified device have finished. It is useful for ensuring synchronization between CPU and GPU or across multiple devices.

Parameters

device (CUDAPlace | CustomPlace | int | str | None, optional) – The target device to synchronize. - None: Synchronize the current device. - int: Device index, e.g., 2 means gpu:2. - str: Device string, e.g., 'cuda:0' or 'gpu:0'. - CUDAPlace: A Paddle CUDA place object. - CustomPlace: A Paddle custom device place object.

Returns

None

Examples

>>> 
>>> import paddle

# synchronize the current device
>>> paddle.cuda.synchronize()