export BART model to ONNX failed with [Segmentation fault (core dumped)]
See original GitHub issueEnvironment info
transformersversion:v4.10.0-dev0- Platform:Ubuntu 18.04.3 LTS
Pythonversion:v3.8.11PyTorchversion (GPU?):v1.9.0-cu102(TRUE)Tensorflowversion (GPU?):Noneonnxversion:v1.10.1onnxruntimversion:v1.8.1- Using GPU in script?:
False - Using distributed or parallel set-up in script?:
False
Who can help
@patrickvonplaten @patil-suraj
Information
Model I am using BART:
The problem arises when using:
- the official example scripts: (give details below)
- my own modified scripts following the command line example given in the official Export transformers models document.
To reproduce
Steps to reproduce the behavior:
1.run the following command line in console:
python -m transformers.onnx --model="lidiya/bart-large-xsum-samsum" --feature=default "lidiya-bart-large-xsum-samsum"
Full log
Some weights of the model checkpoint at lidiya/bart-large-xsum-samsum were not used when initializing BartModel: ['lm_head.weight', 'final_logits_bias']
- This IS expected if you are initializing BartModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
- This IS NOT expected if you are initializing BartModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
Using framework PyTorch: 1.9.0+cu102
Overriding 1 configuration item(s)
- use_cache -> False
/root/miniconda3/envs/speedup/lib/python3.8/site-packages/transformers/models/bart/modeling_bart.py:212: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if attn_weights.size() != (bsz * self.num_heads, tgt_len, src_len):
/root/miniconda3/envs/speedup/lib/python3.8/site-packages/transformers/models/bart/modeling_bart.py:218: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if attention_mask.size() != (bsz, 1, tgt_len, src_len):
/root/miniconda3/envs/speedup/lib/python3.8/site-packages/transformers/models/bart/modeling_bart.py:249: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if attn_output.size() != (bsz * self.num_heads, tgt_len, self.head_dim):
/root/miniconda3/envs/speedup/lib/python3.8/site-packages/transformers/models/bart/modeling_bart.py:863: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if input_shape[-1] > 1:
Validating ONNX model...
Traceback (most recent call last):
Segmentation fault (core dumped)
Expected behavior
Exporting BART model to onnx successfully and can be run on onnxruntime to generate correct results.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Segmentation fault (core dumped) when conversion of GPT-J ...
For example, here's an issue where someone tries to export a >2GB sized model. I tracked down the onnx PR where support for...
Read more >Segmentation Fault when exporting to onnx a quantized ...
FloatFunctional() operators. However, whenever I try to export it with torch.onnx.export(torch_model, # model being run input_example, # ...
Read more >Segmentation fault (core dumped): It crashes when compiling ...
TVM throws Segmentation fault (core dumped) at relay.build() when compile a ONNX model in CUDA. Please notice that: the script run well when ......
Read more >Build TRT engine with onnx QAT model throws segmentation ...
Description Hello I'm trying to build onnx model with quantization aware training following this: it was successful until exporting onnx ...
Read more >Migrating a quantized aware model from Tensorflow - Kneron
We get Segmentation fault (core dumped) when using ktc.kneron_inference on the exported ONNX model, but not when using the same inference on ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello again! I’ve uploaded the converted model here: https://huggingface.co/lysandre/onnx-bart/tree/main (search for model.onnx)
Hmmm I’m failing at reproducing 😦 I have the following versions, could you try installing them to see if it changes something?
I can also upload the converted model to the hub under a repository if that’s helpful for you.