Skip to content

Commit

Permalink
DataModules: use persistent workers for parallel data loading (#2291)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjstewart authored Sep 17, 2024
1 parent 8747aca commit d440c56
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions torchgeo/datamodules/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def _dataloader_factory(self, split: str) -> DataLoader[dict[str, Tensor]]:
batch_sampler=batch_sampler,
num_workers=self.num_workers,
collate_fn=self.collate_fn,
persistent_workers=self.num_workers > 0,
)

def train_dataloader(self) -> DataLoader[dict[str, Tensor]]:
Expand Down Expand Up @@ -429,6 +430,7 @@ def _dataloader_factory(self, split: str) -> DataLoader[dict[str, Tensor]]:
shuffle=split == 'train',
num_workers=self.num_workers,
collate_fn=self.collate_fn,
persistent_workers=self.num_workers > 0,
)

def train_dataloader(self) -> DataLoader[dict[str, Tensor]]:
Expand Down

0 comments on commit d440c56

Please sign in to comment.