DeepLearningExamples icon indicating copy to clipboard operation
DeepLearningExamples copied to clipboard

[Tacotron2-Waveglow/PyTorch] tacotron & waveglow trt engine inference ERROR

Open RaymondTsao opened this issue 6 years ago • 14 comments

Related to Model/Framework(s) [Tacotron2-Waveglow/PyTorch]

Describe the bug

I try inference by pre-trained models is ok: python inference.py --tacotron2 nvidia_tacotron2pyt_fp16_20190427 --waveglow nvidia_waveglowpyt_fp16_20190427 -o output/ --include-warmup -i phrases/phrase_1_64.txt --fp16 --log-file=output/nvlog_fp16.json

Then I try to inference by trt engine,

The follow steps about tacotron + waveglow tensorRT inference, models are from NGC models repository

1. tacotron exports to onnx : python export_tacotron2_onnx.py --tacotron2 nvidia_tacotron2pyt_fp16_20190427 -o exports/ --fp16

2. waveglow 256 channel exports to onnx : python export_waveglow_onnx.py --waveglow audio/nvidia_waveglow256pyt_fp16 --wn-channels 256 -o exports/ --fp16

3. tacotron & waveglow exports onnx to trt engine : python export_onnx2trt.py -o audio/ --encoder exports/encoder.onnx --decoder exports/decoder_iter.onnx --postnet exports/postnet.onnx --waveglow exports/waveglow.onnx --fp16

4. tacotron & waveglow trt engine inference : python inference_trt.py -i test.txt -o audio/ --encoder audio/encoder_fp16.engine --decoder audio/decoder_iter_fp16.engine --postnet audio/postnet_fp16.engine --waveglow audio/waveglow_fp16.engine --fp16

Then I get the following error: [TensorRT] WARNING: TensorRT was linked against cuBLAS 10.2.2 but loaded cuBLAS 10.2.1 [TensorRT] WARNING: TensorRT was linked against cuBLAS 10.2.2 but loaded cuBLAS 10.2.1 [TensorRT] WARNING: TensorRT was linked against cuBLAS 10.2.2 but loaded cuBLAS 10.2.1 [TensorRT] WARNING: TensorRT was linked against cuBLAS 10.2.2 but loaded cuBLAS 10.2.1 Running Tacotron2 Encoder [TensorRT] ERROR: Parameter check failed at: engine.cpp::setBindingDimensions::948, condition: profileMaxDims.d[i] >= dimensions.d[i] [TensorRT] ERROR: Parameter check failed at: engine.cpp::resolveSlots::1092, condition: allInputDimensionsSpecified(routine) Running Tacotron2 Decoder [TensorRT] ERROR: Parameter check failed at: engine.cpp::setBindingDimensions::948, condition: profileMaxDims.d[i] >= dimensions.d[i] [TensorRT] ERROR: Parameter check failed at: engine.cpp::setBindingDimensions::948, condition: profileMaxDims.d[i] >= dimensions.d[i] [TensorRT] ERROR: Parameter check failed at: engine.cpp::setBindingDimensions::948, condition: profileMaxDims.d[i] >= dimensions.d[i] [TensorRT] ERROR: Parameter check failed at: engine.cpp::setBindingDimensions::948, condition: profileMaxDims.d[i] >= dimensions.d[i] [TensorRT] ERROR: Parameter check failed at: engine.cpp::setBindingDimensions::948, condition: profileMaxDims.d[i] >= dimensions.d[i] [TensorRT] ERROR: Parameter check failed at: engine.cpp::resolveSlots::1092, condition: allInputDimensionsSpecified(routine) [TensorRT] ERROR: Parameter check failed at: engine.cpp::setBindingDimensions::948, condition: profileMaxDims.d[i] >= dimensions.d[i] [TensorRT] ERROR: Parameter check failed at: engine.cpp::setBindingDimensions::948, condition: profileMaxDims.d[i] >= dimensions.d[i] [TensorRT] ERROR: Parameter check failed at: engine.cpp::setBindingDimensions::948, condition: profileMaxDims.d[i] >= dimensions.d[i] [TensorRT] ERROR: Parameter check failed at: engine.cpp::setBindingDimensions::948, condition: profileMaxDims.d[i] >= dimensions.d[i] [TensorRT] ERROR: Parameter check failed at: engine.cpp::setBindingDimensions::948, condition: profileMaxDims.d[i] >= dimensions.d[i] [TensorRT] ERROR: Parameter check failed at: engine.cpp::resolveSlots::1092, condition: allInputDimensionsSpecified(routine)

steps 1~3 will output model success, but cannot inference.

Any suggestions about this problem? I try to search this error but it's seldom issues about this.

I will thankful if you answer that Orz...

RaymondTsao avatar Sep 09 '20 02:09 RaymondTsao

Based on the log obviously the problem is in the cuBLAS version: "cuBLAS 10.2.2 but loaded cuBLAS 10.2.1". When converting the models it is important that you use the same version of PyTorch as you will use for the inference. Furthermore, the conversion should also be performed on the same graphic card - e.g. if you will perform inference on T4 also the conversion should be done on T4.

Here you can check the contents of the PyTorch container. You will also see the info about the cuBLAS version.

jmmarko avatar Sep 11 '20 06:09 jmmarko

Based on the log obviously the problem is in the cuBLAS version: "cuBLAS 10.2.2 but loaded cuBLAS 10.2.1". When converting the models it is important that you use the same version of PyTorch as you will use for the inference. Furthermore, the conversion should also be performed on the same graphic card - e.g. if you will perform inference on T4 also the conversion should be done on T4.

Here you can check the contents of the PyTorch container. You will also see the info about the cuBLAS version.

Hi, @jmmarko , appreciate for your feedback.

I converted pre-trained models(from NGC models repository) to trt engine & inference on same environment and same GPU(only one), so the version of Pytorch(1.4.0) also the same as well. So I confused about this error :(

following are my environment version: Pytorch(1.4.0) cuda(10.2.89) cudnn(7.6.5) tensorRT(7.0.0.11)

Add some information about the step 1 output information:

1. tacotron exports to onnx :

python export_tacotron2_onnx.py --tacotron2 nvidia_tacotron2pyt_fp16_20190427 -o exports/ --fp16

Bad key "text.kerning_factor" on line 4 in /workspace_ssd/Anaconda-new/envs/TTS-E2E-env/lib/python3.6/site-packages/matplotlib/mpl-data/stylelib/_classic_test_patch.mplstyle. You probably need to get an updated matplotlibrc file from https://github.com/matplotlib/matplotlib/blob/v3.1.3/matplotlibrc.template or from the matplotlib source distribution checkpoint :nvidia_tacotron2pyt_fp16_20190427 model_config :{'mask_padding': False, 'n_mel_channels': 80, 'n_symbols': 148, 'symbols_embedding_dim': 512, 'encoder_kernel_size': 5, 'encoder_n_convolutions': 3, 'encoder_embedding_dim': 512, 'attention_rnn_dim': 1024, 'attention_dim': 128, 'attention_location_n_filters': 32, 'attention_location_kernel_size': 31, 'n_frames_per_step': 1, 'decoder_rnn_dim': 1024, 'prenet_dim': 256, 'max_decoder_steps': 2000, 'gate_threshold': 0.5, 'p_attention_dropout': 0.1, 'p_decoder_dropout': 0.1, 'postnet_embedding_dim': 512, 'postnet_kernel_size': 5, 'postnet_n_convolutions': 5, 'decoder_no_early_stopping': False} export_tacotron2_onnx.py:62: TracerWarning: Converting a tensor to a NumPy array 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! input_lengths_cpu = input_lengths_cpu.cpu().numpy() # TODO export_tacotron2_onnx.py:64: UserWarning: pack_padded_sequence has been called with a Python list of sequence lengths. The tracer cannot track the data flow of Python values, and it will treat them as constants, likely rendering the trace incorrect for any other combination of lengths. x, input_lengths_cpu, batch_first=True) /workspace_ssd/Anaconda-new/envs/TTS-E2E-env/lib/python3.6/site-packages/torch/onnx/symbolic_opset9.py:1436: UserWarning: Exporting a model to ONNX with a batch_size other than 1, with a variable lenght with LSTM can cause an error when running the ONNX model with a different batch size. Make sure to save the model with a batch size of 1, or define the initial states (h0/c0) as inputs of the model. "or define the initial states (h0/c0) as inputs of the model. ") Running Tacotron2 Encoder Running Tacotron2 Decoder Stopping after 143 decoder steps Running Tacotron2 PostNet

it seems something UserWarning in the tacotron exports to onnx

RaymondTsao avatar Sep 11 '20 07:09 RaymondTsao

If you have the same environment that this warning is really strange. Are you using Docker or you have setup the environment locally on the machine by yourself?

jmmarko avatar Sep 11 '20 08:09 jmmarko

If you have the same environment that this warning is really strange. Are you using Docker or you have setup the environment locally on the machine by yourself?

Hi, @jmmarko, I used the local machine with virtual environment, not Docker

RaymondTsao avatar Sep 11 '20 08:09 RaymondTsao

Maybe try it using a Docker since all the environment is already setup there. With this, you will be able to test if there is something missing in your environment. I transformed all the models without any problems so far.

jmmarko avatar Sep 11 '20 08:09 jmmarko

Maybe try it using a Docker since all the environment is already setup there. With this, you will be able to test if there is something missing in your environment. I transformed all the models without any problems so far.

OK, I will try in Docker. Thank you so much for helping

RaymondTsao avatar Sep 11 '20 08:09 RaymondTsao

Maybe try it using a Docker since all the environment is already setup there. With this, you will be able to test if there is something missing in your environment. I transformed all the models without any problems so far.

hi, @jmmarko, I try to it again in container following step by step

but engine inference have OOM error:

python trt/inference_trt.py -i test.txt --encoder output/encoder_fp16.engine --decoder output/decoder_iter_fp16.engine --postnet output/postnet_fp16.engine --waveglow output/waveglow_fp16.engine -o output/ --fp16

[TensorRT] ERROR: ../rtSafe/safeRuntime.cpp (25) - Cuda Error in allocate: 2 (out of memory) [TensorRT] ERROR: FAILED_ALLOCATION: std::exception Traceback (most recent call last): File "trt/inference_trt.py", line 385, in main() File "trt/inference_trt.py", line 344, in main sequences = sequences.to(torch.int32) RuntimeError: CUDA error: out of memory

have any suggestions? thanks a lot.

RaymondTsao avatar Sep 14 '20 08:09 RaymondTsao

The problem is with the memory of your GPU. Which GPU do you use? Use can check how much memory is used by running nvidia-smi. I would guess that the problem is in your test.txt. Try with a very short text (1 line, 130 chars) to see if it works.

jmmarko avatar Sep 15 '20 09:09 jmmarko

The problem is with the memory of your GPU. Which GPU do you use? Use can check how much memory is used by running nvidia-smi. I would guess that the problem is in your test.txt. Try with a very short text (1 line, 130 chars) to see if it works.

Hi, @jmmarko, appreciate you still feedback : )

I use only one GeForce RTX 2080 Ti, Memory-Usage 26MiB / 11016MiB

Did you try with multiple GPUs?

my test.txt is like following:

The forms of printed letters should be beautiful. She sells seashells by the seashore, shells she sells are great The forms of printed letters should be beautiful.

and I try even ONLY one or two words also out of memory.... :(

RaymondTsao avatar Sep 18 '20 01:09 RaymondTsao

Ok, this is getting really strange now... 11GB of RAM should be more than enough. So I don't have any good idea what else could go wrong. You can also try and follow the instructions provided in the folder trtis_cpp, and see if this will work for you.

What is your usecase anyway? How would you like to use it in the end?

jmmarko avatar Sep 18 '20 06:09 jmmarko

Ok, this is getting really strange now... 11GB of RAM should be more than enough. So I don't have any good idea what else could go wrong. You can also try and follow the instructions provided in the folder trtis_cpp, and see if this will work for you.

What is your usecase anyway? How would you like to use it in the end?

@jmmarko , ok, I will try in trtis_cpp folder, thanks your reply : )

I just need to decrease my own model synthesis time on GPU. Did you really speedup your inference time by tensorrt engine ?

RaymondTsao avatar Sep 18 '20 08:09 RaymondTsao

Yes, you do. In that case, the other option trtis_cpp will be even better because it ensemble both models, so that all (whole synthesis) is done on the GPU, and it uses the Triton server. Give it a try.

jmmarko avatar Sep 18 '20 09:09 jmmarko

Yes, you do. In that case, the other option trtis_cpp will be even better because it ensemble both models, so that all (whole synthesis) is done on the GPU, and it uses the Triton server. Give it a try.

Hi, @jmmarko. trtis_cpp is work, grateful for your help. : )

RaymondTsao avatar Sep 22 '20 06:09 RaymondTsao

@jmmarko I have been also doing some trials and it seems that 11GB are not enough. I finally succedeed with a Titan 12GB Pascal but modifying the file "tensorrt/convert_onnx2trt.py"

I modified Postnet shapes to:

shapes=[{"name": "mel_outputs", "min": (1,80,32), "opt": (1,80,768), "max": (1,80,1300)}]`

And the WaveGlow shapes to:

shapes=[{"name": "mel", "min": (1,80,32),  "opt": (1,80,768),  "max": (1,80,1300)},
        {"name": "z",   "min": (1,8,1024), "opt": (1,8,24576), "max": (1,8,41600)}]

ivangtorre avatar Jan 27 '21 11:01 ivangtorre