facebookresearch / fairseq

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

TypeError: 'NoneType' object is not iterable in torch.hub.list('pytorch/fairseq') #1062

Closed sekewei closed 5 years ago

sekewei commented 5 years ago

import torch

List available models

torch.hub.list('pytorch/fairseq', force_reload=True) # [..., 'transformer_lm.wmt19.en', ...]

When running the above torch.hub command on 'pytorch/fairseq', the folloinwg TypeError on default='cross_entropy' is shown.

Downloading: "https://github.com/pytorch/fairseq/archive/master.zip" to /root/.cache/torch/hub/master.zip

TypeError Traceback (most recent call last)

in () 2 3 # List available models ----> 4 torch.hub.list('pytorch/fairseq', force_reload=True) # [..., 'transformer_lm.wmt19.en', ...] 5 6 # Load an English LM trained on WMT'19 News Crawl data 6 frames /root/.cache/torch/hub/pytorch_fairseq_master/fairseq/criterions/__init__.py in () 14 '--criterion', 15 base_class=FairseqCriterion, ---> 16 default='cross_entropy', 17 ) 18 TypeError: 'NoneType' object is not iterable
sekewei commented 5 years ago

Maybe the following error is related as it is shown when running torch.hub.list('pytorch/fairseq', force_reload=True) for the first time.

 ModuleNotFoundError: No module named 'fairseq.data.data_utils_fast'

TypeError is shown the second time when running torch.hub.list('pytorch/fairseq', force_reload=True) by ignoring the first error message.

sekewei commented 5 years ago

Just found that 'fairseq.data.data_utils_fast' module is available in 'pyx' format. It requires the following build process for inplace access.

 ~/fairseq$  python setup.py build_ext --inplace

After the inplace build process, an .so shared object is generated for module import.

 ~/fairseq$ ls  fairseq/data/data_utils*
fairseq/data/data_utils_fast.cpp
fairseq/data/data_utils_fast.cpython-37m-x86_64-linux-gnu.so
fairseq/data/data_utils_fast.pyx
fairseq/data/data_utils.py
ngoyal2707 commented 5 years ago

Yes, we recently introduced cython dependency to the fairseq code to make data loading faster. So if you have recently git pulled, you will need to build the *.so files.

BrazilForever11 commented 5 years ago

Would there be any instructions on how to build *.so files?

ngoyal2707 commented 5 years ago

@BrazilForever11 Yes, we just landed https://github.com/pytorch/fairseq/commit/396ff7f59f027a98d2df9951ed15045bdd91554b which prints nicer error msg with instruction to build cython component.

You need to run

pip install --editable .

from within the fairseq folder where setup.py exists.

ayushidalmia commented 3 years ago

This is still happening in the master

JoaTesseracto commented 2 years ago

This is still happening to me. ¡Anyone with the same problem? What's the workaround?

arpcode commented 2 years ago

This is still happening, any workaround?

chloe68 commented 2 years ago

It's happening to me too. Does anyone have the solution?

LoganLiu66 commented 2 years ago

Still happening on data2vec audio infer.

ogala8 commented 1 year ago

I had the same issue. Apparently upgrading tokenizers was helpful... From: https://stackoverflow.com/questions/68528187/cant-load-transformers-models/70832410#70832410?newreg=130314ccc1094a2cb6ec8ec1cd12228d

VidushiVashishth commented 1 year ago

The problem is still happening. It is happening on loading a model in google colab also:

import torch roberta = torch.hub.load('pytorch/fairseq', 'roberta.large.mnli', force_reload=True)

Error message


[~/.cache/torch/hub/pytorch_fairseq_main/fairseq/criterions/__init__.py](https://localhost:8080/#) in <module>
     16 
     17 
---> 18 (
     19     build_criterion_,
     20     register_criterion,

TypeError: cannot unpack non-iterable NoneType object
deepak2107 commented 1 year ago

hello was anyone able to find a solution , facing the same issue on google colab.

TypeError Traceback (most recent call last) in 8 9 ---> 10 xlmr = torch.hub.load('pytorch/fairseq', 'xlmr.large')

7 frames ~/.cache/torch/hub/pytorch_fairseq_main/fairseq/criterions/init.py in 16 17 ---> 18 ( 19 buildcriterion, 20 register_criterion,

TypeError: cannot unpack non-iterable NoneType object