dmlc / gluon-nlp

NLP made easy

Home Page:https://nlp.gluon.ai/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug][Conversion Tools] mxnet block.py Overriding Parameter attribute %s is not allowed

makua-bernal opened this issue · comments

Description

When using the conversion tools to convert a roberta model the following error occurs.

Error Message

Traceback (most recent call last):
  File "convert_fairseq_roberta.py", line 386, in <module>
    convert_fairseq_model(args)
  File "convert_fairseq_roberta.py", line 355, in convert_fairseq_model
    gluon_roberta = convert_params(fairseq_roberta,
  File "convert_fairseq_roberta.py", line 174, in convert_params
    gluon_model = RobertaForMLM(backbone_cfg=gluon_cfg)
  File "/home/user/.local/lib/python3.8/site-packages/mxnet/util.py", line 297, in _with_np_shape
    return func(*args, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/mxnet/util.py", line 481, in _with_np_array
    return func(*args, **kwargs)
  File "/home/user/gluon-nlp/src/gluonnlp/models/roberta.py", line 484, in __init__
    self.mlm_decoder[-1].weight = self.backbone_model.word_embed.weight
  File "/home/user/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 886, in __setattr__
    super(HybridBlock, self).__setattr__(name, value)
  File "/home/user/.local/lib/python3.8/site-packages/mxnet/gluon/block.py", line 305, in __setattr__
    assert name not in self._reg_params, \
AssertionError: Overriding Parameter attribute %s is not allowed. If you want to share parameters between blocks, please set 'params' at Block construction instead.

To Reproduce

gluonnlp version 1.0.0.dev20210116
mxnet version 1.7.0.post1
fairseq version 1.0.0a0+4a6f89d

bash convert_roberta.sh

@jumpily You may need to install MXNet 2.0 and try again. You can try out the following commands:

# Install the version with CUDA 10.1
python3 -m pip install -U --pre "mxnet-cu101>=2.0.0b20201206" -f https://dist.mxnet.io/python

# Install the version with CUDA 10.2
python3 -m pip install -U --pre "mxnet-cu102>=2.0.0b20201206" -f https://dist.mxnet.io/python

# Install the version with CUDA 11
python3 -m pip install -U --pre "mxnet-cu110>=2.0.0b20201206" -f https://dist.mxnet.io/python

# Install the cpu-only version
python3 -m pip install -U --pre "mxnet>=2.0.0b20201206" -f https://dist.mxnet.io/python

@sxjscience That seems to have worked, thank you! Are the converted models compatible with lower MXNet versions?

@jumpily i’ll close this issue since it has been solved. Feel free to reopen.