multi-model-server icon indicating copy to clipboard operation
multi-model-server copied to clipboard

ONNX to .mar conversion

Open steve-1820 opened this issue 5 years ago • 5 comments

Hey guys, great library.

I'm having trouble converting a ONNX model to the .mar format using the steps outlined here:

https://github.com/awslabs/mxnet-model-server/blob/f8845f917187957d0ae44c6a44b8fecec6746811/model-archiver/docs/convert_from_onnx.md

The .mar file is created but every time I attempt inference, my backend workers will die due to onnx-squeezenet-symbol.json not being found.

Here is the exact error:

mxnet.base.MXNetError: [22:32:47] src/io/local_filesys.cc:199: Check failed: allow_null LocalFileSystem::Open "/home/model-server/tmp/models/788e08a42eec410e09f18c0426ba2ca9fd513b64/onnx-squeezenet-symbol.json": No such file or directory

Let me know if you want more details.

steve-1820 avatar Nov 12 '19 22:11 steve-1820

From my understanding, when we archive a model we typically need these files to define the model/weights:

  • squeezenet_v1.1-symbol.json
  • squeezenet_v1.1-0000.params

For the ONNX representation, since the model has the .onnx extension, it will be detected and the converted to mxnet models accordingly without the need for the symbol and params files.

However obviously as with the above error, it seems like this is not the case? Is it a bug in the model-archiver?

steve-1820 avatar Nov 12 '19 23:11 steve-1820

Morning team,

Any update for the above? @vdantu

Steve

steve-1820 avatar Nov 17 '19 22:11 steve-1820

Model archiver needs an additional -c flag to convert ONNX models to MXNet models. Added a small fix in the documents.

vdantu avatar Nov 25 '19 22:11 vdantu

It appears that the -c option produces an error.

model-archiver -c --model-name onnx-squeezenet --model-path ./my_model --handler mxnet_vision_service:handle ERROR - Failed to write the signature or symbol files for squeezenet.onnx model Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/bin/model-archiver", line 8, in sys.exit(generate_model_archive()) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/model_archiver/model_packaging.py", line 63, in generate_model_archive package_model(args, manifest=manifest) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/model_archiver/model_packaging.py", line 40, in package_model t, files_to_exclude = ModelExportUtils.check_custom_model_types(model_path, model_name) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/model_archiver/model_packaging_utils.py", line 93, in check_custom_model_types symbol_file, params_file = ModelExportUtils.convert_onnx_model(model_path, onnx_file, model_name) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/model_archiver/model_packaging_utils.py", line 174, in convert_onnx_model with open(os.path.join(model_path, signature_file), 'r') as f: FileNotFoundError: [Errno 2] No such file or directory: './my_model/signature.json'

quantum-fusion avatar Aug 05 '20 09:08 quantum-fusion

without the -c option the command works just fine. model-archiver —model-name onnx-squeezenet —model-path ./my_model —handler mxnet_vision_service:handle

quantum-fusion avatar Aug 05 '20 09:08 quantum-fusion