Skip to content

Commit

Permalink
Merge branch 'simple-cache' into gpu-transform
Browse files Browse the repository at this point in the history
  • Loading branch information
ziw-liu committed Oct 31, 2024
2 parents c185377 + 2ca134b commit 70fcf1c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions viscy/data/hcs_ram.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,11 @@ def _setup_fit(self, dataset_settings: dict) -> None:
)

def train_dataloader(self) -> DataLoader:
sampler = ShardedDistributedSampler(self.train_dataset, shuffle=True)
if is_ddp_enabled():
sampler = ShardedDistributedSampler(self.train_dataset, shuffle=True)
else:
sampler = None
_logger.info("Using standard sampler for non-distributed training")
return DataLoader(
self.train_dataset,
batch_size=self.batch_size // self.train_patches_per_stack,
Expand All @@ -333,7 +337,12 @@ def train_dataloader(self) -> DataLoader:
)

def val_dataloader(self) -> DataLoader:
sampler = ShardedDistributedSampler(self.val_dataset, shuffle=False)
if is_ddp_enabled():
sampler = ShardedDistributedSampler(self.val_dataset, shuffle=False)
else:
sampler = None
_logger.info("Using standard sampler for non-distributed validation")

return DataLoader(
self.val_dataset,
batch_size=self.batch_size,
Expand Down

0 comments on commit 70fcf1c

Please sign in to comment.