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

question about run code in training on one gpu #5

Open
wuliwan opened this issue Apr 14, 2021 · 3 comments
Open

question about run code in training on one gpu #5

wuliwan opened this issue Apr 14, 2021 · 3 comments

Comments

@wuliwan
Copy link

wuliwan commented Apr 14, 2021

Hello, when I enter code with "python tools/train.py configs/swin/upernet_swin_tiny_patch4_window7_512x512_160k_ade20k.py --options model.pretrained=models/upernet_swin_tiny_patch4_window7_512x512.pth [model.backbone.use_checkpoint=True]" on my windows,it happened:
(RTX3090) D:\Swin-Transformer-Semantic-Segmentation>python tools/train.py configs/swin/upernet_swin_tiny_patch4_window7_512x512_160k_ade20k.py --options model.pretrained=models/upernet_swin_tiny_patch4_window7_512x512.pth [model.backbone.use_checkpoint=True]
.\work_dirs\upernet_swin_tiny_patch4_window7_512x512_160k_ade20k
Traceback (most recent call last):
File "D:\Anaconda\envs\RTX3090\lib\site-packages\yapf\yapflib\pytree_utils.py", line 115, in ParseCodeToTree
tree = parser_driver.parse_string(code, debug=False)
File "D:\Anaconda\envs\RTX3090\lib\lib2to3\pgen2\driver.py", line 104, in parse_string
return self.parse_tokens(tokens, debug)
File "D:\Anaconda\envs\RTX3090\lib\lib2to3\pgen2\driver.py", line 72, in parse_tokens
if p.addtoken(type, value, (prefix, start)):
File "D:\Anaconda\envs\RTX3090\lib\lib2to3\pgen2\parse.py", line 159, in addtoken
raise ParseError("bad input", type, value, context)
lib2to3.pgen2.parse.ParseError: bad input: type=3, value="'model'", context=('\n', (4, 0))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Anaconda\envs\RTX3090\lib\site-packages\yapf\yapflib\pytree_utils.py", line 121, in ParseCodeToTree
tree = parser_driver.parse_string(code, debug=False)
File "D:\Anaconda\envs\RTX3090\lib\lib2to3\pgen2\driver.py", line 104, in parse_string
return self.parse_tokens(tokens, debug)
File "D:\Anaconda\envs\RTX3090\lib\lib2to3\pgen2\driver.py", line 72, in parse_tokens
if p.addtoken(type, value, (prefix, start)):
File "D:\Anaconda\envs\RTX3090\lib\lib2to3\pgen2\parse.py", line 159, in addtoken
raise ParseError("bad input", type, value, context)
lib2to3.pgen2.parse.ParseError: bad input: type=3, value="'model'", context=('\n', (4, 0))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "tools/train.py", line 164, in
main()
File "tools/train.py", line 101, in main
cfg.dump(osp.join(cfg.work_dir, osp.basename(args.config)))
File "D:\Anaconda\envs\RTX3090\lib\site-packages\mmcv\utils\config.py", line 458, in dump
f.write(self.pretty_text)
File "D:\Anaconda\envs\RTX3090\lib\site-packages\mmcv\utils\config.py", line 413, in pretty_text
text, _ = FormatCode(text, style_config=yapf_style, verify=True)
File "D:\Anaconda\envs\RTX3090\lib\site-packages\yapf\yapflib\yapf_api.py", line 147, in FormatCode
tree = pytree_utils.ParseCodeToTree(unformatted_source)
File "D:\Anaconda\envs\RTX3090\lib\site-packages\yapf\yapflib\pytree_utils.py", line 127, in ParseCodeToTree
raise e
File "D:\Anaconda\envs\RTX3090\lib\site-packages\yapf\yapflib\pytree_utils.py", line 125, in ParseCodeToTree
ast.parse(code)
File "D:\Anaconda\envs\RTX3090\lib\ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "", line 4
'model': dict(
^
SyntaxError: invalid syntax

so I want ask the run code example for windows when I train on one gpu?

@impiga
Copy link
Member

impiga commented Apr 19, 2021

Hi, @wuliwan

Which version of python do you use? By google searching ib2to3.pgen2.parse.ParseError: bad input: type=3, value="'model'", context=('\n', (4, 0)), I found that this error may be caused by lower version of python (see this issue).

You could try with python 3.7 or 3.8.

@maisonhai3
Copy link

I got the same error.

It is not because of Python version.

In my case, the error comes from the config file.

Reason
In config file, everything should be a dictionary, ONLY dictionary,
but I wrote some codes to define classes,
codes to do this do that,
then those lines of codes caused that error.

Solution:
Keep only lines that define the model structure.

@Bestxyz
Copy link

Bestxyz commented May 31, 2021

I got the same error.

It is not because of Python version.

In my case, the error comes from the config file.

Reason
In config file, everything should be a dictionary, ONLY dictionary,
but I wrote some codes to define classes,
codes to do this do that,
then those lines of codes caused that error.

Solution:
Keep only lines that define the model structure.

Can you tell me how to modify the code? thank you very much

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

4 participants