DistributedDataParallel (既可单机多卡又可多机多卡)
先奉上官网nn.DistributedDataParallel(model)链接
https://pytorch.org/docs/stable/generated/torch.nn.parallel.DistributedDataParallel.html#torch.nn.parallel.DistributedDataParallelpytorch.org
-
CLASS torch.nn.parallel.DistributedDataParallel(module, device_ids=None, output_device=None, -
dim=0, broadcast_buffers=True, process_group=None, bucket_cap_mb=25, -
find_unused_parameters=False, check_reduction=False)
- 参数定义
module是要放到多卡训练的模型;
device_ids数据类型是一个列表, 表示可用的gpu卡号;
output_devices数据类型也是列表,表示模型输出
本文详细介绍了如何使用torch.nn.DistributedDataParallel进行多GPU训练,包括单机多卡和多机多卡的配置。讲解了初始化过程,如设置backend、init_method、rank、world_size,并强调了TCP初始化和使用DistributedSampler的重要性。此外,还探讨了模型的保存和加载策略,以及在多GPU训练中使用dist.barrier()的必要性。
订阅专栏 解锁全文
1万+

被折叠的 条评论
为什么被折叠?



