-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation fault with emformer #335
Comments
Do you train the.model by yourself? Does our provided model.work? |
Thank you for your fast answer. Yes, i trained the model by myself. I wrote "streaming-ncnn-decode works" that was wrong. I mean "decode.py and streaming_decode.py" works. I followed this doc: https://icefall.readthedocs.io/en/latest/model-export/export-ncnn-conv-emformer.html
don't know if the log is okay ... seems wrong with zipformer and 'open failed', but i get the nccn-bins and params
2024-05-03 11:33:11,783 INFO [streaming-ncnn-decode.py:349] Constructing Fbank computer Error in: encoder_out, states = model.run_encoder(frames, states) => ret, ncnn_out0 = ex.extract("out0") |
Please describe how you checked that. Also, please answer whether you have followed exactly the following doc Hint:
|
I trained with this params: ./conv_emformer_transducer_stateless2/train.py I tried to use the params from the small model: https://huggingface.co/marcoyang/sherpa-ncnn-conv-emformer-transducer-small-2023-01-09/blob/main/export-ncnn.sh It seems that there is no "--bpe-model", so I used "tokens.txt" as described in the documentation: ./conv_emformer_transducer_stateless2/export-for-ncnn.py The output was similar to the documentation. Except: emformer2.py:614: 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! The files appear to have been created. With pnnx encoder i get this output: fp16 = 1 The missing "--bpe-model" like in your sherpa-ncnn-conv-emformer-transducer-small-2023-01-09 isn't a problem?
I tried to but I can't guarantee. I'll retry in few days. Thank you for the hint and your help. Just if it's interesting: I tested with sherpa-ncnn and streaming-ncnn on different systems but get the same error but your "sherpa-ncnn-conv-emformer-transducer-small-2023-01-09 " works well. |
If you follow the doc exactly, there should not be any issues. Please try to export with our provided pytorch checkpoint and make sure you can reproduce it. |
Pytorch checkpoint? The documentation states: "We are using Ubuntu 18.04, Torch 1.13 and Python 3.8 for testing" and "Please use a newer version of PyTorch". I am using “2.1.1+cu121”. I'm not sure if pnnx uses the same cuda version, but if I rebuild everything on a clean system, it's no problem to use 2.1.1, right? |
pytorch checkpoint is a .pt file. I suggest you to follow the doc step by step using our provided checkpoint. |
Hello, I'm currently testing the emformer model and have copied the parameters from "sherpa-cnn-conv-emformer-transducer-small-2023-01-09" into my own model. While the finished emformer model (2023-01-09) is running I get "Segmentation fault" in my own model:
icefall:~/bin$ ./sherpa-ncnn ./test/tokens.txt ./test/encoder_jit_trace-pnnx.ncnn.param ./test/encoder_jit_trace-pnnx.ncnn.bin ./test/decoder_jit_trace-pnnx.ncnn.param ./test/decoder_jit_trace-pnnx.ncnn.bin ./test/joiner_jit_trace-pnnx.ncnn.param ./test/joiner_jit_trace-pnnx.ncnn.bin test.wav
RecognizerConfig(feat_config=FeatureExtractorConfig(sampling_rate=16000, feature_dim=80), model_config=ModelConfig(encoder_param="./test/encoder_jit_trace-pnnx.ncnn.param", encoder_bin="./test/encoder_jit_trace-pnnx.ncnn.bin", decoder_param="./test/decoder_jit_trace-pnnx.ncnn.param", decoder_bin="./test/decoder_jit_trace-pnnx.ncnn.bin", joiner_param="./test/joiner_jit_trace-pnnx.ncnn.param", joiner_bin="./test/joiner_jit_trace-pnnx.ncnn.bin", tokens="./test/tokens.txt", encoder num_threads=4, decoder num_threads=4, joiner num_threads=4), decoder_config=DecoderConfig(method="greedy_search", num_active_paths=4), endpoint_config=EndpointConfig(rule1=EndpointRule(must_contain_nonsilence=False, min_trailing_silence=2.4, min_utterance_length=0), rule2=EndpointRule(must_contain_nonsilence=True, min_trailing_silence=1.4, min_utterance_length=0), rule3=EndpointRule(must_contain_nonsilence=False, min_trailing_silence=0, min_utterance_length=20)), enable_endpoint=False, hotwords_file="", hotwrods_score=1.5)
wav filename: test.wav
wav duration (s): 28.89
Started!
Segmentation fault (core dumped)
I trained two epochs for testing, then exported with "https://github.com/k2-fsa/icefall/blob/master/egs/librispeech/ASR/conv_emformer_transducer_stateless2/export-for-ncnn.py" (streaming-ncnn-decode works) and converted with pnnx. Here is the pnnx log:
./pnnx ~/icefall/egs/test/ASR/conv_emformer_transducer_stateless2/exp/decoder_jit_trace-pnnx.pt
pnnxparam = ~/icefall/egs/test/ASR/conv_emformer_transducer_stateless2/exp/decoder_jit_trace-pnnx.pnnx.param
pnnxbin = ~/icefall/egs/test/ASR/conv_emformer_transducer_stateless2/exp/decoder_jit_trace-pnnx.pnnx.bin
pnnxpy = ~/icefall/egs/test/ASR/conv_emformer_transducer_stateless2/exp/decoder_jit_trace-pnnx_pnnx.py
pnnxonnx = ~/icefall/egs/test/ASR/conv_emformer_transducer_stateless2/exp/decoder_jit_trace-pnnx.pnnx.onnx
ncnnparam = ~/icefall/egs/test/ASR/conv_emformer_transducer_stateless2/exp/decoder_jit_trace-pnnx.ncnn.param
ncnnbin = ~/icefall/egs/test/ASR/conv_emformer_transducer_stateless2/exp/decoder_jit_trace-pnnx.ncnn.bin
ncnnpy = ~/icefall/egs/test/ASR/conv_emformer_transducer_stateless2/exp/decoder_jit_trace-pnnx_ncnn.py
fp16 = 1
optlevel = 2
device = cpu
inputshape =
inputshape2 =
customop =
moduleop = scaling_converter.PoolingModuleNoProj,zipformer.AttentionDownsampleUnsqueeze,zipformer_for_ncnn_export_only.AttentionDownsampleUnsqueeze
############# pass_level0
############# pass_level1
############# pass_level2
############# pass_level3
open failed
############# pass_level4
############# pass_level5
pnnx build without onnx-zero support, skip saving onnx
############# pass_ncnn
Encoder, decoder and joiner have relatively similar output. Even though I use an emformer, it always says zipformer and I also see "open failed" with every conversion.
It would be nice if someone here had a tip.
The text was updated successfully, but these errors were encountered: