Skip to content

Commit

Permalink
Merge 89ff56e into d131a87
Browse files Browse the repository at this point in the history
  • Loading branch information
Dai-Wenxun authored Nov 10, 2022
2 parents d131a87 + 89ff56e commit aa75e87
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion configs/_base_/default_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
logger=dict(type='LoggerHook', interval=20, ignore_last=False),
param_scheduler=dict(type='ParamSchedulerHook'),
checkpoint=dict(type='CheckpointHook', interval=1, save_best='auto'),
sampler_seed=dict(type='DistSamplerSeedHook'))
sampler_seed=dict(type='DistSamplerSeedHook'),
sync_buffers=dict(type='SyncBuffersHook'))

env_cfg = dict(
cudnn_benchmark=False,
Expand Down
3 changes: 3 additions & 0 deletions docs/en/user_guides/4_train_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ CUDA_VISIBLE_DEVICES=-1 python tools/train.py ${CONFIG_FILE} [ARGS]
| `--amp` | Enable automatic-mixed-precision training. |
| `--no-validate` | **Not suggested**. Disable checkpoint evaluation during training. |
| `--auto-scale-lr` | Auto scale the learning rate according to the actual batch size and the original batch size. |
| `--seed` | Random seed. |
| `--diff-rank-seed` | Whether or not set different seeds for different ranks. |
| `--deterministic` | Whether to set deterministic options for CUDNN backend. |
| `--cfg-options CFG_OPTIONS` | Override some settings in the used config, the key-value pair in xxx=yyy format will be merged into the config file. If the value to be overwritten is a list, it should be of the form of either `key="[a,b]"` or `key=a,b`. The argument also allows nested list/tuple values, e.g. `key="[(a,b),(c,d)]"`. Note that the quotation marks are necessary and that no white space is allowed. |
| `--launcher {none,pytorch,slurm,mpi}` | Options for job launcher. Defaults to `none`. |

Expand Down
16 changes: 16 additions & 0 deletions tools/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ def parse_args():
action='store_true',
help='whether to auto scale the learning rate according to the '
'actual batch size and the original batch size.')
parser.add_argument('--seed', type=int, default=None, help='random seed')
parser.add_argument(
'--diff-rank-seed',
action='store_true',
help='whether or not set different seeds for different ranks')
parser.add_argument(
'--deterministic',
action='store_true',
help='whether to set deterministic options for CUDNN backend.')
parser.add_argument(
'--cfg-options',
nargs='+',
Expand Down Expand Up @@ -96,6 +105,13 @@ def merge_args(cfg, args):
if args.auto_scale_lr:
cfg.auto_scale_lr.enable = True

# set random seeds
if cfg.get('randomness', None) is None:
cfg.randomness = dict(
seed=args.seed,
diff_rank_seed=args.diff_rank_seed,
deterministic=args.deterministic)

if args.cfg_options is not None:
cfg.merge_from_dict(args.cfg_options)

Expand Down

0 comments on commit aa75e87

Please sign in to comment.