allenai / PRIMER

The official code for PRIMERA: Pyramid-based Masked Sentence Pre-training for Multi-document Summarization
Apache License 2.0
153 stars 32 forks source link

OSError: Unable to load weights from pytorch checkpoint file #5

Closed thangld201 closed 2 years ago

thangld201 commented 2 years ago

Firstly, thanks for the excellent work. I'm trying the PRIMER model, and facing the following error when loading model:

from transformers import AutoTokenizer
from longformer import LongformerEncoderDecoderForConditionalGeneration
from longformer import LongformerEncoderDecoderConfig

tokenizer = AutoTokenizer.from_pretrained('/content/PRIMER/PRIMER/')
config = LongformerEncoderDecoderConfig.from_pretrained('/content/PRIMER/PRIMER/')
model = LongformerEncoderDecoderForConditionalGeneration.from_pretrained(
            '/content/PRIMER/PRIMER/', config=config)
/usr/local/lib/python3.7/dist-packages/transformers/modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
    857             except Exception:
    858                 raise OSError(
--> 859                     "Unable to load weights from pytorch checkpoint file. "
    860                     "If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True. "
    861                 )

OSError: Unable to load weights from pytorch checkpoint file. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True. 

I was running on Google Colaboratory, and skipped the Conda install part for simplicity. Is this why I got the above error ?

thangld201 commented 2 years ago

Sorry, I just realized that I was not running in GPU-enabled mode, which was the primary cause.