Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

ONNX export not working #403

Open
ykim362 opened this issue Mar 20, 2019 · 5 comments
Open

ONNX export not working #403

ykim362 opened this issue Mar 20, 2019 · 5 comments

Comments

@ykim362
Copy link

ykim362 commented Mar 20, 2019

pytorch_translate/examples/export_iwslt14.sh

This example doesn't work for me.
Would you be able to help me to run the example script?

I tried to fix the errors one by one, by removing parameters, but couldn't succeed to export.

  1. onnx_component_export.py: error: unrecognized arguments: --batched-beam
  2. File "/data/repos/translate/pytorch_translate/rnn.py", line 526, in build_single_decoder
    fp16=args.fp16,
    AttributeError: 'Namespace' object has no attribute 'fp16'
  3. Exception has occurred: RuntimeError
    Error(s) in loading state_dict for RNNModel: Missing key(s) in state_dict: "encoder.bilstm.layers.0.weight_ih_l0", "encoder.bilstm.layers.0.weight_hh_l0", "encoder.bilstm.layers.0.bias_ih_l0", "encoder.bilstm.layers.0.bias_hh_l0", "encoder.bilstm.layers.0.weight_ih_l0_reverse", "encoder.bilstm.layers.0.weight_hh_l0_reverse", "encoder.bilstm.layers.0.bias_ih_l0_reverse", "encoder.bilstm.layers.0.bias_hh_l0_reverse", "encoder.bilstm.layers.1.weight_ih_l0", "encoder.bilstm.layers.1.weight_hh_l0", "encoder.bilstm.layers.1.bias_ih_l0", "encoder.bilstm.layers.1.bias_hh_l0". Unexpected key(s) in state_dict: "encoder.layers.0.weight_ih_l0", "encoder.layers.0.weight_hh_l0", "encoder.layers.0.bias_ih_l0", "encoder.layers.0.bias_hh_l0", "encoder.layers.0.weight_ih_l0_reverse", "encoder.layers.0.weight_hh_l0_reverse", "encoder.layers.0.bias_ih_l0_reverse", "encoder.layers.0.bias_hh_l0_reverse", "encoder.layers.1.weight_ih_l0", "encoder.layers.1.weight_hh_l0", "encoder.layers.1.bias_ih_l0", "encoder.layers.1.bias_hh_l0".
    File "\opt\conda\lib\python3.6\site-packages\torch\nn\modules\module.py", line 771, in load_state_dict
    File "\opt\conda\lib\python3.6\site-packages\fairseq\models\fairseq_model.py", line 66, in load_state_dict
    File "D:\repos\translate\pytorch_translate\ensemble_export.py", line 122, in load_models_from_checkpoints
    File "D:\repos\translate\pytorch_translate\ensemble_export.py", line 414, in build_from_checkpoints
    File "D:\repos\translate\pytorch_translate\onnx_component_export.py", line 116, in export
    File "D:\repos\translate\pytorch_translate\onnx_component_export.py", line 88, in main
    File "D:\repos\translate\pytorch_translate\onnx_component_export.py", line 156, in
@ykim362
Copy link
Author

ykim362 commented Mar 21, 2019

I re-trained an RNN model instead of using the pre-trained model because of the name mismatch (version issue?).
"encoder.bilstm.layers.0.weight_ih_l0 vs. encoder.layers.0.weight_ih_l0"

So, I got encoder and decoder pb files.

When I tried to build cpp, it generated error message that Caffe2 is not found.
I installed Caffe2 (pytorch) as in https://caffe2.ai/docs/getting-started.html?platform=ubuntu&configuration=compile.

Could you help me to resolve this issue?


CMake Error at CMakeLists.txt:19 (find_package):
  By not providing "FindCaffe2.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Caffe2", but
  CMake did not find one.

  Could not find a package configuration file provided by "Caffe2" with any
  of the following names:

    Caffe2Config.cmake
    caffe2-config.cmake

  Add the installation prefix of "Caffe2" to CMAKE_PREFIX_PATH or set
  "Caffe2_DIR" to a directory containing one of the above files.  If "Caffe2"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!

@jmp84
Copy link
Contributor

jmp84 commented Mar 21, 2019

@ykim362, thanks for the report. I'm in the process of updating the examples. We will also replace the ONNX solution with a PyTorch native export.

@ykim362
Copy link
Author

ykim362 commented Mar 21, 2019

@jmp84 Thanks for the information!

I have one more question.

Replacing ONNX solution with a PyTorch native export

Does this mean Torch Script?
https://pytorch.org/tutorials/advanced/cpp_export.html

Or, another solution?

@jmp84
Copy link
Contributor

jmp84 commented Mar 21, 2019

@ykim362, yes, I meant Torch Script.

@tsauri
Copy link

tsauri commented Apr 2, 2019

Does the next update support export to Caffe2?
How does export with Torch Script works with Caffe2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants