Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mmsegmentation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Bartels
mmsegmentation
Commits
da6bb2c8
Commit
da6bb2c8
authored
3 years ago
by
Rockey
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[Feature]: Add diff seeds to diff ranks and set torch seed in worker_init_fn (#1362)
parent
98b8ed37
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mmseg/datasets/builder.py
+1
-0
1 addition, 0 deletions
mmseg/datasets/builder.py
tools/train.py
+6
-0
6 additions, 0 deletions
tools/train.py
with
7 additions
and
0 deletions
mmseg/datasets/builder.py
+
1
−
0
View file @
da6bb2c8
...
...
@@ -186,3 +186,4 @@ def worker_init_fn(worker_id, num_workers, rank, seed):
worker_seed
=
num_workers
*
rank
+
worker_id
+
seed
np
.
random
.
seed
(
worker_seed
)
random
.
seed
(
worker_seed
)
torch
.
manual_seed
(
worker_seed
)
This diff is collapsed.
Click to expand it.
tools/train.py
+
6
−
0
View file @
da6bb2c8
...
...
@@ -8,6 +8,7 @@ import warnings
import
mmcv
import
torch
import
torch.distributed
as
dist
from
mmcv.cnn.utils
import
revert_sync_batchnorm
from
mmcv.runner
import
get_dist_info
,
init_dist
from
mmcv.utils
import
Config
,
DictAction
,
get_git_hash
...
...
@@ -50,6 +51,10 @@ def parse_args():
help
=
'
id of gpu to use
'
'
(only applicable to non-distributed training)
'
)
parser
.
add_argument
(
'
--seed
'
,
type
=
int
,
default
=
None
,
help
=
'
random seed
'
)
parser
.
add_argument
(
'
--diff_seed
'
,
action
=
'
store_true
'
,
help
=
'
Whether or not set different seeds for different ranks
'
)
parser
.
add_argument
(
'
--deterministic
'
,
action
=
'
store_true
'
,
...
...
@@ -180,6 +185,7 @@ def main():
# set random seeds
seed
=
init_random_seed
(
args
.
seed
)
seed
=
seed
+
dist
.
get_rank
()
if
args
.
diff_seed
else
seed
logger
.
info
(
f
'
Set random seed to
{
seed
}
,
'
f
'
deterministic:
{
args
.
deterministic
}
'
)
set_random_seed
(
seed
,
deterministic
=
args
.
deterministic
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment