mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-05 16:41:04 +08:00
scaled batch size
This commit is contained in:
@@ -162,16 +162,12 @@ class LightningTemplateModel(LightningModule):
|
||||
train_sampler = None
|
||||
batch_size = self.hparams.batch_size
|
||||
|
||||
# try:
|
||||
# if self.on_gpu:
|
||||
import torch.distributed as dist
|
||||
print(dist.get_world_size())
|
||||
train_sampler = DistributedSampler(dataset, rank=self.trainer.proc_rank)
|
||||
batch_size = batch_size // self.trainer.world_size # scale batch size
|
||||
print(batch_size)
|
||||
|
||||
# except Exception as e:
|
||||
# pass
|
||||
try:
|
||||
if self.on_gpu:
|
||||
train_sampler = DistributedSampler(dataset, rank=self.trainer.proc_rank)
|
||||
batch_size = batch_size // self.trainer.world_size # scale batch size
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
should_shuffle = train_sampler is None
|
||||
loader = DataLoader(
|
||||
|
||||
Reference in New Issue
Block a user