Open
Description
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'
Activity
wangcongcong123 commentedon Dec 14, 2021
Have you tried down-version the transformers?
usmanali-arshi commentedon Dec 15, 2021
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 commentedon Feb 27, 2022
Try using transformers 3.5.0. It works for me.
vishalsingha commentedon May 25, 2022
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