Open erip opened 5 years ago
Downgrading to Python 3.6 yields:
(pytext) ➜ pytext git:(master) ✗ pytext export --output-path exported_model.c2 < demo/configs/docnn.json
No config file specified, reading from stdin
Exporting /tmp/model.pt to caffe2 file: exported_model.c2 and onnx file: /tmp/model.onnx
Loading model from /tmp/model.pt...
Task parameters:
{'data_handler': {'columns_to_read': ['doc_label', 'text', 'dict_feat'],
'eval_batch_size': 128,
'eval_path': 'tests/data/test_data_tiny.tsv',
'max_seq_len': -1,
'shuffle': True,
'sort_within_batch': True,
'test_batch_size': 128,
'test_path': 'tests/data/test_data_tiny.tsv',
'train_batch_size': 128,
'train_path': 'tests/data/train_data_tiny.tsv'},
'exporter': None,
'features': {'char_feat': None,
'dense_feat': None,
'dict_feat': None,
'freeze': False,
'load_path': None,
'pretrained_model_embedding': None,
'save_path': None,
'shared_module_key': None,
'word_feat': {'embed_dim': 100,
'embedding_init_range': None,
'embedding_init_strategy': 'random',
'export_input_names': ['tokens_vals'],
'freeze': False,
'lowercase_tokens': True,
'min_freq': 1,
'mlp_layer_dims': [],
'pretrained_embeddings_path': '',
'vocab_file': '',
'vocab_from_all_data': False,
'vocab_from_pretrained_embeddings': False,
'vocab_from_train_data': True,
'vocab_size': 0}},
'featurizer': {'SimpleFeaturizer': {'convert_to_bytes': False,
'lowercase_tokens': True,
'sentence_markers': None,
'split_regex': '\\s+'}},
'labels': {'export_output_names': ['doc_scores'],
'label_weights': {},
'target_prob': False},
'metric_reporter': {'output_path': '/tmp/test_out.txt'},
'model': {'decoder': {'freeze': False,
'hidden_dims': [],
'load_path': None,
'save_path': None,
'shared_module_key': None},
'output_layer': {'freeze': False,
'load_path': None,
'loss': {'CrossEntropyLoss': {}},
'save_path': None,
'shared_module_key': None},
'representation': {'BiLSTMDocAttention': {'dropout': 0.4,
'freeze': False,
'load_path': None,
'lstm': {'bidirectional': True,
'dropout': 0.4,
'freeze': False,
'load_path': None,
'lstm_dim': 32,
'num_layers': 1,
'save_path': None,
'shared_module_key': None},
'mlp_decoder': None,
'pooling': {'SelfAttention': {'attn_dimension': 64,
'dropout': 0.4}},
'save_path': None,
'shared_module_key': None}}},
'optimizer': {'lr': 0.001,
'momentum': 0.0,
'type': 'adam',
'weight_decay': 1e-05},
'scheduler': {'T_max': 1000,
'cooldown': 0,
'cut_frac': 0.1,
'eta_min': 0.0,
'gamma': 0.1,
'lm_gradual_unfreezing': True,
'lm_lr_multiplier': 1.0,
'lm_use_per_layer_lr': False,
'non_pretrained_param_groups': 2,
'patience': 5,
'ratio': 32,
'step_size': 30,
'threshold': 0.0001,
'threshold_is_absolute': False,
'type': 'none'},
'trainer': {'early_stop_after': 0,
'epochs': 10,
'max_clip_norm': None,
'random_seed': 0,
'report_train_metrics': True}}
creating field TextFeatureField
creating field DocLabelField
Loading data...
load_path is not a config of embedding, skipping
save_path is not a config of embedding, skipping
freeze is not a config of embedding, skipping
shared_module_key is not a config of embedding, skipping
dict_feat is not a config of embedding, skipping
char_feat is not a config of embedding, skipping
pretrained_model_embedding is not a config of embedding, skipping
dense_feat is not a config of embedding, skipping
Model has 2 param groups (1 from embedding module) for optimizer
Saving caffe2 model to: exported_model.c2
Saving onnx model to: /tmp/model.onnx
/data/erippeth/anaconda3/envs/pytext/lib/python3.6/site-packages/torch/nn/modules/module.py:487: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
result = self._slow_forward(*input, **kwargs)
Traceback (most recent call last):
File "/data/erippeth/anaconda3/envs/pytext/bin/pytext", line 11, in <module>
sys.exit(main())
File "/data/erippeth/anaconda3/envs/pytext/lib/python3.6/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/data/erippeth/anaconda3/envs/pytext/lib/python3.6/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/data/erippeth/anaconda3/envs/pytext/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/data/erippeth/anaconda3/envs/pytext/lib/python3.6/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/data/erippeth/anaconda3/envs/pytext/lib/python3.6/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/data/erippeth/anaconda3/envs/pytext/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/data/erippeth/anaconda3/envs/pytext/lib/python3.6/site-packages/pytext/main.py", line 303, in export
export_saved_model_to_caffe2(model, output_path, output_onnx_path)
File "/data/erippeth/anaconda3/envs/pytext/lib/python3.6/site-packages/pytext/workflow.py", line 130, in export_saved_model_to_caffe2
task.export(task.model, export_caffe2_path, export_onnx_path=output_onnx_path)
File "/data/erippeth/anaconda3/envs/pytext/lib/python3.6/site-packages/pytext/task/task.py", line 189, in export
self.exporter.export_to_caffe2(model, export_path, export_onnx_path)
File "/data/erippeth/anaconda3/envs/pytext/lib/python3.6/site-packages/pytext/exporters/exporter.py", line 192, in export_to_caffe2
export_onnx_path,
File "/data/erippeth/anaconda3/envs/pytext/lib/python3.6/site-packages/pytext/utils/onnx_utils.py", line 50, in pytorch_to_caffe2
onnx.checker.check_model(onnx_model)
File "/data/erippeth/anaconda3/envs/pytext/lib/python3.6/site-packages/onnx/checker.py", line 86, in check_model
C.check_model(model.SerializeToString())
onnx.onnx_cpp2py_export.checker.ValidationError: No Op or Function registered for ConstantFill with domain_version of 9
==> Context: Bad node spec: input: "75" output: "76" op_type: "ConstantFill" attribute { name: "input_as_shape" i: 1 type: INT }
Repro confirmed on linux (ubuntu). Works on mac.
FWIW:
➜ ~ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
We recently removed ConstantFill
from onnx operator set, since it's an experimental operator. We also stop emitting ConstantFill
in PyTorch as well. However, the release version is not out yet. So short term solution is install the previous release version of ONNX. I am wondering how the onnx is installed on your system. if you use pip, could you try pip install onnx==1.3.0
and check whether you still have the problem or not.
A related PR https://github.com/facebookresearch/pytext/pull/241, which pin onnx version in requirements
My system had onnx 1.4.1. Once I pinned it to 1.3.0, it still segfaults with python 3.7.2; it completes successfully with python 3.6.8.
I adding wheel for python 3.7 as well. Hopefully, that may solve the problem.
Steps to reproduce
git clone git@github.com:facebookresearch/pytext.git
conda create -n pytext -y
conda activate pytext
conda intall pip
pip install pytext-nlp
cd pytext
pytext train < demo/configs/docnn.json
pytext test < demo/configs/docnn.json
pytext export --output-path exported_model.c2 < demo/configs/docnn.json
Observed Results
Expected Results