awslabs / multi-model-server

Multi Model Server is a tool for serving neural net models for inference

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong version of ONNX as requirement of model-archiver[onnx]

tbagrel1 opened this issue · comments

OS: KDE Neon 20.04 (Ubuntu 20.04 based)
Python: 3.8

To convert an ONNX model to the .mar format, I followed the following guide.
However, when trying to convert the model using the command given in the example, I get the following error:

ERROR - Failed to import age-imdb_wiki.onnx file to onnx. Verify if the model file is valid
Traceback (most recent call last):
  File "/home/thomas/.local/bin/model-archiver", line 8, in <module>
    sys.exit(generate_model_archive())
  File "/home/thomas/.local/lib/python3.8/site-packages/model_archiver/model_packaging.py", line 63, in generate_model_archive
    package_model(args, manifest=manifest)
  File "/home/thomas/.local/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 "/home/thomas/.local/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 "/home/thomas/.local/lib/python3.8/site-packages/model_archiver/model_packaging_utils.py", line 165, in convert_onnx_model
    sym, arg_params, aux_params = onnx_mxnet.import_model(os.path.join(model_path, onnx_file))
  File "/home/thomas/.local/lib/python3.8/site-packages/mxnet/contrib/onnx/onnx2mx/import_model.py", line 58, in import_model
    model_proto = onnx.load_model(model_file)
AttributeError: module 'onnx' has no attribute 'load_model'

Bumping the ONNX version from 1.1.1 (requirement of model-archiver[onnx]) to the latest version available (via pip3 install onnx --upgrade, which gives onnx 1.8.0) solves this problem. I think the issue can be solved easily in updating the requirements of the model-archiver module.