本文簡要介紹python語言中 torch.distributed.gather_object
的用法。
用法:
torch.distributed.gather_object(obj, object_gather_list=None, dst=0, group=None)
沒有。在
dst
等級上,object_gather_list
將包含集體的輸出。在單個進程中從整個組中收集 picklable 的對象。與
gather()
類似,但可以傳入Python對象。請注意,該對象必須是可picklable的才能被收集。注意
請注意,此 API 與聚集集合略有不同,因為它不提供 async_op 句柄,因此將是一個阻塞調用。
注意
請注意,使用 NCCL 後端時不支持此 API。
警告
gather_object()
隱式使用pickle
模塊,已知這是不安全的。可以構造惡意的 pickle 數據,該數據將在 unpickling 期間執行任意代碼。僅使用您信任的數據調用此函數。>>> # Note: Process group initialization omitted on each rank. >>> import torch.distributed as dist >>> # Assumes world_size of 3. >>> gather_objects = ["foo", 12, {1: 2}] # any picklable object >>> output = [None for _ in gather_objects] >>> dist.gather_object( gather_objects[dist.get_rank()], output if dist.get_rank() == 0 else None, dst=0 ) >>> # On rank 0 >>> output ['foo', 12, {1: 2}]
例子:
參數:
返回:
相關用法
- Python PyTorch gather用法及代碼示例
- Python PyTorch gammainc用法及代碼示例
- Python PyTorch gammaincc用法及代碼示例
- Python PyTorch gammaln用法及代碼示例
- Python PyTorch gumbel_softmax用法及代碼示例
- Python PyTorch get_tokenizer用法及代碼示例
- Python PyTorch gradient用法及代碼示例
- Python PyTorch global_unstructured用法及代碼示例
- Python PyTorch greedy_partition用法及代碼示例
- Python PyTorch get_gradients用法及代碼示例
- Python PyTorch get_ignored_functions用法及代碼示例
- Python PyTorch get_default_dtype用法及代碼示例
- Python PyTorch gt用法及代碼示例
- Python PyTorch gcd用法及代碼示例
- Python PyTorch get_graph_node_names用法及代碼示例
- Python PyTorch get_testing_overrides用法及代碼示例
- Python PyTorch generate_sp_model用法及代碼示例
- Python PyTorch ge用法及代碼示例
- Python PyTorch frexp用法及代碼示例
- Python PyTorch jvp用法及代碼示例
- Python PyTorch cholesky用法及代碼示例
- Python PyTorch vdot用法及代碼示例
- Python PyTorch ELU用法及代碼示例
- Python PyTorch ScaledDotProduct.__init__用法及代碼示例
- Python PyTorch saved_tensors_hooks用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.distributed.gather_object。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。