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

Error when running run_clm.py on Python3.9/MacOS #9452

Closed
liyucheng09 opened this issue Jan 7, 2021 · 5 comments
Closed

Error when running run_clm.py on Python3.9/MacOS #9452

liyucheng09 opened this issue Jan 7, 2021 · 5 comments

Comments

@liyucheng09
Copy link

Environment info

  • transformers version: 4.1.1
  • Platform: macOS-11.0-arm64-arm-64bit
  • Python version: 3.9.1
  • PyTorch version (GPU?): 1.8.0a0+c20b916 (False)
  • Tensorflow version (GPU?): not installed
  • Using GPU in script?: No
  • Using distributed or parallel set-up in script?: No

Information

Model I am using (Bert, XLNet ...): GPT2

The problem arises when using:

  • [yes ] the official example scripts: (give details below)

The tasks I am working on is:

  • [no] an official GLUE/SQUaD task: language-modeling task; dataset: wikitext

To reproduce

Steps to reproduce the behavior:

  1. install transformers from the master branch of version 4.1.1
  2. run examples/language-modeling/run_clm.py
  3. arguments are as following: --model_name_or_path gpt2 --dataset_name wikitext --dataset_config_name wikitext-2-raw-v1 --do_train --do_eval --output_dir test-clm/
/Users/liyucheng/miniforge3/bin/python /Users/liyucheng/projects/comments_generation/run_clm.py --model_name_or_path gpt2 --dataset_name wikitext --dataset_config_name wikitext-2-raw-v1 --do_train --do_eval --output_dir test-clm/
Traceback (most recent call last):
  File "/Users/liyucheng/projects/comments_generation/run_clm.py", line 388, in <module>
    main()
  File "/Users/liyucheng/projects/comments_generation/run_clm.py", line 145, in main
    parser = HfArgumentParser((ModelArguments, DataTrainingArguments, TrainingArguments))
  File "/Users/liyucheng/miniforge3/lib/python3.9/site-packages/transformers/hf_argparser.py", line 52, in __init__
    self._add_dataclass_arguments(dtype)
  File "/Users/liyucheng/miniforge3/lib/python3.9/site-packages/transformers/hf_argparser.py", line 85, in _add_dataclass_arguments
    elif hasattr(field.type, "__origin__") and issubclass(field.type.__origin__, List):
  File "/Users/liyucheng/miniforge3/lib/python3.9/typing.py", line 829, in __subclasscheck__
    return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class

Process finished with exit code 1

This error is bizarre cause it only occurs on my OSX and I cannot reproduce it on my PC.

I think the main reason is about the decorator dataset, but I am not sure about that.

Thanks for any helps.

@LysandreJik
Copy link
Member

It seems quite cryptic, but maybe @sgugger has already been confronted to that issue, so pinging him here.

@sgugger
Copy link
Collaborator

sgugger commented Jan 7, 2021

Never seen this before. There is some code in the HFArgumentParser to make it work with Python 3.9 that was added by @julien-c so maybe he has more insight?

@liyucheng09
Copy link
Author

liyucheng09 commented Jan 8, 2021

I want to provide more valuable information about this issue.

The field of the corresponding argument --model_name_of_path on my Mac/Python3.9 is like the following:

Field(name='model_name_or_path',type=typing.Optional[str],default=None,default_factory=<dataclasses._MISSING_TYPE object at 0x1065a6220>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'help': "The model checkpoint for weights initialization.Don't set if you want to train a model from scratch."}),_field_type=_FIELD)

However, it is different on my PC/Python3.7.9.

Field(name='model_name_or_path',type=typing.Union[str, NoneType],default=None,default_factory=<dataclasses._MISSING_TYPE object at 0x00000227D9888A48>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'help': "The model checkpoint for weights initialization.Don't set if you want to train a model from scratch."}),_field_type=_FIELD)

The critical change of it is the type attribute. The function in transformers/data_classes.py do not give type=typing.Optional[str] a appropriate solution.

But, I have no idea why the type attribute has that different value when I run it on Mac/Python3.9.1.

@sgugger
Copy link
Collaborator

sgugger commented Jan 8, 2021

#9479 will fix this I believe.

@LysandreJik
Copy link
Member

Closed by #9479!

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

3 participants