broadcast_object_list¶
- paddle.distributed. broadcast_object_list ( object_list, src, group=None ) [source]
-
Broadcast picklable objects from the source to all others. Similiar to broadcast(), but python object can be passed in.
- Parameters
-
object_list (list) – The list of objects to send if current rank is the source, or the list of objects to receive otherwise.
src (int) – The source rank in global view.
group (Group) – The group instance return by new_group or None for global default group.
- Returns
-
None.
Warning
This API only supports the dygraph mode.
Examples
>>> >>> import paddle.distributed as dist >>> dist.init_parallel_env() >>> if dist.get_rank() == 0: ... object_list = [{"foo": [1, 2, 3]}] >>> else: ... object_list = [{"bar": [4, 5, 6]}] >>> dist.broadcast_object_list(object_list, src=1) >>> print(object_list) >>> # [{"bar": [4, 5, 6]}] (2 GPUs)