Skip to content

Commit f13516d

Browse files
authored
Update seed.py
1 parent e48acd2 commit f13516d

File tree

1 file changed

+2
-1
lines changed
  • src/lightning/fabric/utilities

1 file changed

+2
-1
lines changed

src/lightning/fabric/utilities/seed.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ def pl_worker_init_function(worker_id: int, rank: Optional[int] = None) -> None:
9191
9292
"""
9393
# implementation notes: https://github.com/pytorch/pytorch/issues/5059#issuecomment-817392562
94+
assert "PL_GLOBAL_SEED" in os.environ, "`seed_everything(seed, workers=True)` must be called before training to use this function."
9495
global_rank = rank if rank is not None else rank_zero_only.rank
95-
process_seed = torch.initial_seed()
96+
process_seed = int(os.environ["PL_GLOBAL_SEED"])
9697
# back out the base seed so we can use all the bits
9798
base_seed = process_seed - worker_id
9899
log.debug(

0 commit comments

Comments
 (0)