Skip to content

Commit

Permalink
fix sanity check (#2310)
Browse files Browse the repository at this point in the history
  • Loading branch information
izhx committed Jan 9, 2024
1 parent 55d4a49 commit 0d2280d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/accelerate/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,8 @@ def prepare_data_loader(
process_index = state.process_index

# Sanity check
if split_batches and dataloader.batch_size > 1 and dataloader.batch_size % num_processes != 0:
batch_size = dataloader.batch_size if dataloader.batch_size is not None else dataloader.batch_sampler.batch_size
if split_batches and batch_size > 1 and batch_size % num_processes != 0:
raise ValueError(
f"To use a `DataLoader` in `split_batches` mode, the batch size ({dataloader.batch_size}) "
f"needs to be a round multiple of the number of processes ({num_processes})."
Expand Down

0 comments on commit 0d2280d

Please sign in to comment.