Closed Ravoxsg closed 3 years ago
You have not explained how you created your model
or how you launch this script. The stack trace indicates there is a DistributedDataParallel
involved and some distributed launch. As the error indicates the model wrapped in a DistributedDataParallel
is not a Transformers model anymore and has no generate
method, you need to access the model you wrapped like this: model.module
to get back you Transformers model. So model.module.generate
.
Calling model.module.generate()
indeed fixed it, thank you @sgugger !
Closing this issue then, glad your problem is fixed!
Hi,
I am trying to generate text with the model.generate() function of HuggingFace. However, it does not work with neither 1 or more than 1 GPUs, and I get the following error:
I don't have any error when not in generation mode though. My setup is the following:
I am using MT5ForConditionalGeneration as model.
And here is my validate function:
`def validate(mode, loader, tokenizer, model, device, scores, args): model.eval()