-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Use
--diff-seed
to set different torch seed on different …
…rank (#781) * [Feature]: Add diff seeds to diff ranks and set torch seed in worker_init_fn * [Feature]: Add diff seeds to diff ranks and set torch seed in worker_init_fn * Update train.py
- Loading branch information
Showing
5 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) OpenMMLab. All rights reserved. | ||
import torch | ||
|
||
from mmedit.apis.train import init_random_seed, set_random_seed | ||
|
||
|
||
def test_init_random_seed(): | ||
init_random_seed(0, device='cpu') | ||
init_random_seed(device='cpu') | ||
# test on gpu | ||
if torch.cuda.is_available(): | ||
init_random_seed(0, device='cuda') | ||
init_random_seed(device='cuda') | ||
|
||
|
||
def test_set_random_seed(): | ||
set_random_seed(0, deterministic=False) | ||
set_random_seed(0, deterministic=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters