facebookresearch / fairseq

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
MIT License
30.43k stars 6.4k forks source link

[XLM-RoBERTa] Cannot find callable xlmr.large in hubconf #1509

Closed stefan-it closed 4 years ago

stefan-it commented 4 years ago

Hi,

thanks for releasing the final base and large models for XLM-RoBERTa.

Unfortunately, the models can't be loaded from torch.hub:

import torch
xlmr = torch.hub.load('pytorch/fairseq', 'xlmr.large')

The following error message is thrown:

RuntimeError                              Traceback (most recent call last)
<ipython-input-19-30bbbd5d0579> in <module>
      1 import torch
      2 print(torch.__version__)
----> 3 xlmr = torch.hub.load('pytorch/fairseq', 'xlmr.large')
      4 xlmr.eval()  # disable dropout (or leave in train mode to finetune)

/media/stefan/00eb2e8f-6826-4043-a1d7-937b9d5341c1/.venvs/flair/lib/python3.7/site-packages/torch/hub.py in load(github, model, *args, **kwargs)
    355     hub_module = import_module(MODULE_HUBCONF, repo_dir + '/' + MODULE_HUBCONF)
    356 
--> 357     entry = _load_entry_from_hubconf(hub_module, model)
    358 
    359     model = entry(*args, **kwargs)

/media/stefan/00eb2e8f-6826-4043-a1d7-937b9d5341c1/.venvs/flair/lib/python3.7/site-packages/torch/hub.py in _load_entry_from_hubconf(m, model)
    228 
    229     if func is None or not callable(func):
--> 230         raise RuntimeError('Cannot find callable {} in hubconf'.format(model))
    231 
    232     return func

RuntimeError: Cannot find callable xlmr.large in hubconf

I'm using PyTorch 1.3.1 and I cleared the .cache/torch folder.

Before loading the message:

Using cache found in /home/stefan/.cache/torch/hub/pytorch_fairseq_master

appears. I checked the model.py file in the fairseq/models/roberta folder and it does include the xlmr hub definition 🤔

(Downloading the model manually + loading it works as a workaround).

myleott commented 4 years ago

Please try:

xlmr = torch.hub.load('pytorch/fairseq', 'xlmr.large', force_reload=True)
myleott commented 4 years ago

Also, if that still doesn't work, what happens if you run:

torch.hub.list('pytorch/fairseq')
stefan-it commented 4 years ago

Thanks, it was working with the force_reload=True option :heart: