Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

argparse.ArgumentError: argument --batch_size: conflicting option string: --batch_size #1

Open
waduhekx opened this issue Aug 18, 2022 · 1 comment

Comments

@waduhekx
Copy link

when i try to train stage1, and got this error, is there anyone who konw how fix it? plz. look for your reply.

ArgumentParser(prog='main.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=False)
Traceback (most recent call last):
File "main.py", line 1450, in
main(get_args())
File "main.py", line 1390, in get_args
parser = BirdClef2021DataModule.add_argparse_args(parser)
File "D:\Anaconda\envs\birdclef\lib\site-packages\pytorch_lightning\core\datamodule.py", line 75, in add_argparse_args
return add_argparse_args(cls, parent_parser, **kwargs)
File "D:\Anaconda\envs\birdclef\lib\site-packages\pytorch_lightning\utilities\argparse.py", line 268, in add_argparse_args
parser.add_argument(
File "D:\Anaconda\envs\birdclef\lib\argparse.py", line 1386, in add_argument
return self._add_action(action)
File "D:\Anaconda\envs\birdclef\lib\argparse.py", line 1590, in _add_action
action = super(_ArgumentGroup, self)._add_action(action)
File "D:\Anaconda\envs\birdclef\lib\argparse.py", line 1400, in _add_action
self._check_conflict(action)
File "D:\Anaconda\envs\birdclef\lib\argparse.py", line 1539, in _check_conflict
conflict_handler(action, confl_optionals)
File "D:\Anaconda\envs\birdclef\lib\argparse.py", line 1548, in _handle_conflict_error
raise ArgumentError(action, message % conflict_string)
argparse.ArgumentError: argument --batch_size: conflicting option string: --batch_size

@tattaka
Copy link
Owner

tattaka commented Aug 19, 2022

Sorry for the messy source code!

The reason is that both LightningDataModule and LightningModule use the same argparse argument.
The error can be resolved by defining the arguments that are used only in one of the modules in each and defining the arguments that are used in both in the main function.
I hope this helps you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants