{"record":{"id":"e52f8c69d2349698","repo":"open-mmlab/mmdetection","slug":"config-is-now-expected-to-have-a-runner-section","errorCode":null,"errorMessage":"config is now expected to have a `runner` section, please set `runner` in your config.","messagePattern":"config is now expected to have a `runner` section, please set `runner` in your config\\.","errorType":"console","errorClass":"UserWarning","httpStatus":null,"severity":"warning","filePath":"mmdet/utils/compat_config.py","lineNumber":28,"sourceCode":"    config.\n\n    For example, it will move some args which will be deprecated to the correct\n    fields.\n    \"\"\"\n    cfg = copy.deepcopy(cfg)\n    cfg = compat_imgs_per_gpu(cfg)\n    cfg = compat_loader_args(cfg)\n    cfg = compat_runner_args(cfg)\n    return cfg\n\n\ndef compat_runner_args(cfg):\n    if 'runner' not in cfg:\n        cfg.runner = ConfigDict({\n            'type': 'EpochBasedRunner',\n            'max_epochs': cfg.total_epochs\n        })\n        warnings.warn(\n            'config is now expected to have a `runner` section, '\n            'please set `runner` in your config.', UserWarning)\n    else:\n        if 'total_epochs' in cfg:\n            assert cfg.total_epochs == cfg.runner.max_epochs\n    return cfg\n\n\ndef compat_imgs_per_gpu(cfg):\n    cfg = copy.deepcopy(cfg)\n    if 'imgs_per_gpu' in cfg.data:\n        warnings.warn('\"imgs_per_gpu\" is deprecated in MMDet V2.0. '\n                      'Please use \"samples_per_gpu\" instead')\n        if 'samples_per_gpu' in cfg.data:\n            warnings.warn(\n                f'Got \"imgs_per_gpu\"={cfg.data.imgs_per_gpu} and '\n                f'\"samples_per_gpu\"={cfg.data.samples_per_gpu}, \"imgs_per_gpu\"'\n                f'={cfg.data.imgs_per_gpu} is used in this experiments')","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/utils/compat_config.py#L10-L46","documentation":"compat_runner_args in mmdet/utils/compat_config.py fires when a config lacks a runner section but still carries the MMDet V1.x-style total_epochs key. It auto-creates cfg.runner = {'type': 'EpochBasedRunner', 'max_epochs': total_epochs} so training proceeds, then warns that configs are expected to declare runner explicitly in V2.x style.","triggerScenarios":"Running a training entrypoint (tools/train.py) or any code path that calls compat_cfg(cfg) with a config that defines total_epochs=N but no runner=dict(...) block. The assert branch fires instead if both exist and disagree: assert cfg.total_epochs == cfg.runner.max_epochs.","commonSituations":"Porting old MMDet V1.x configs or community configs to V2.x; upgrading mmdetection versions where runner was introduced; copy-pasting a legacy config into a newer install.","solutions":["Replace total_epochs = 12 in your config with runner = dict(type='EpochBasedRunner', max_epochs=12).","If you must keep total_epochs for compat, also set runner with a matching max_epochs so the assert passes.","For IterBasedRunner-style training use runner = dict(type='IterBasedRunner', max_iters=...) and keep total_epochs out of the config.","Re-run compat_cfg() after edits to confirm the warning disappears."],"exampleFix":"# before\ntotal_epochs = 12\n# after\nrunner = dict(type='EpochBasedRunner', max_epochs=12)","handlingStrategy":"validation","validationCode":"from mmcv import Config\n\ndef check_runner(cfg: Config) -> Config:\n    if 'runner' not in cfg:\n        cfg.runner = dict(type='EpochBasedRunner', max_epochs=cfg.get('total_epochs', 12))\n    cfg.pop('total_epochs', None)\n    return cfg","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always author configs with an explicit runner section in mmdet 2.x.","Lint configs with a startup check that asserts 'runner' in cfg before training.","Never mix total_epochs and runner.max_epochs with mismatched values (the code asserts)."],"tags":["mmdetection","config","deprecation","migration","runner"],"backgroundTag":"deprecated-config-key","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}