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

Not generating required output #10

Open
usmanali-arshi opened this issue Oct 31, 2021 · 4 comments
Open

Not generating required output #10

usmanali-arshi opened this issue Oct 31, 2021 · 4 comments

Comments

@usmanali-arshi
Copy link

When I try to input : "def factorial", it gives me the following error. Could you please help me resolve it? Thanks.

File "interact.py", line 52, in
outputs = model.generate(input_ids=input_ids.to("cuda") if args.use_cuda else input_ids,
File "/home/ua383/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 575, in getattr
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'GPT2LMHeadModel' object has no attribute 'generate'

@wangcongcong123
Copy link
Owner

Have you tried down-version the transformers?

@usmanali-arshi
Copy link
Author

Thanks for getting back to me. I've managed to run it but when I try to fine-tune it on your dataset it gives me this error:
Traceback (most recent call last):
File "train.py", line 83, in
model_trainer = ModelTrainer(model,
File "/home/ua383/work/auto_coding/trainer.py", line 328, in init
self.optimizer = optimizer_class(optimizer_grouped_parameters, **optimizer_params)
File "/home/ua383/anaconda3/envs/training/lib/python3.8/site-packages/transformers/optimization.py", line 301, in init
require_version("torch>=1.5.0") # add
with alpha
File "/home/ua383/anaconda3/envs/training/lib/python3.8/site-packages/transformers/utils/versions.py", line 114, in require_version
_compare_versions(op, got_ver, want_ver, requirement, pkg, hint)
File "/home/ua383/anaconda3/envs/training/lib/python3.8/site-packages/transformers/utils/versions.py", line 49, in _compare_versions
raise ImportError(
ImportError: torch>=1.5.0 is required for a normal functioning of this module, but found torch==1.4.0.

Although I tried installing torch>=1.5.0 versions, it still gives me the same error. Could you please help me with this issue. Thanks.

@Penguin-jpg
Copy link

When I try to input : "def factorial", it gives me the following error. Could you please help me resolve it? Thanks.

File "interact.py", line 52, in outputs = model.generate(input_ids=input_ids.to("cuda") if args.use_cuda else input_ids, File "/home/ua383/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 575, in getattr raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'GPT2LMHeadModel' object has no attribute 'generate'

Try using transformers 3.5.0. It works for me.

@vishalsingha
Copy link

Try installing torch>=1.5 using the below code after uninstalling it

!pip install torch==1.5.1+cu101 torchvision==0.6.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html

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