Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2415,8 +2415,12 @@ def _wrap_model(self, model: nn.Module, training: bool = True, dataloader: DataL
return model
return smp.DistributedModel(model, backward_passes_per_step=self.args.gradient_accumulation_steps)

# Multi-gpu training, 8bit models does not support DP
if self.args.n_gpu > 1 and not getattr(model, "is_loaded_in_8bit", False):
# Multi-gpu training, quantized models do not support DP
if (
self.args.n_gpu > 1
and not getattr(model, "is_loaded_in_8bit", False)
and not getattr(model, "is_loaded_in_4bit", False)
):
model = nn.DataParallel(model)

# Note: in torch.distributed mode, there's no point in wrapping the model
Expand Down
Loading