apache / mxnet

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more
https://mxnet.apache.org
Apache License 2.0
20.73k stars 6.81k forks source link

onnx import not working #20317

Open egiacomazzi opened 3 years ago

egiacomazzi commented 3 years ago

Description

When I try to load this linked model using the following lines of code:

from mxnet.contrib import onnx as onnx_mxnet
onnx_model_file = "network.onnx"
sym, arg, aux = onnx_mxnet.import_model(onnx_model_file)

I get the following...

Error Message

Traceback (most recent call last): File "mxnet_load_onnx.py", line 7, in sym, arg, aux = onnx_mxnet.import_model(onnx_model_file) File "/home/elena/.local/lib/python3.8/site-packages/mxnet/contrib/onnx/onnx2mx/import_model.py", line 60, in import_model sym, arg_params, aux_params = graph.from_onnx(model_proto.graph, opset_version=model_opset_version) File "/home/elena/.local/lib/python3.8/site-packages/mxnet/contrib/onnx/onnx2mx/import_onnx.py", line 117, in from_onnx mxnet_sym = self._convert_operator(node_name, op_name, onnx_attr, inputs) File "/home/elena/.local/lib/python3.8/site-packages/mxnet/contrib/onnx/onnx2mx/import_onnx.py", line 62, in _convert_operator op_name, new_attrs, inputs = convert_map[op_name](attrs, inputs, self) File "/home/elena/.local/lib/python3.8/site-packages/mxnet/contrib/onnx/onnx2mx/_op_translations.py", line 497, in reshape reshape_shape = list(proto_obj._params[inputs[1].name].asnumpy()) KeyError: 'Concat_408'

To Reproduce

The onnx file was produced by exporting from PyTorch using the following code.

torch.onnx.export(torch_model,               # model being run
                  x,                         # model input (or a tuple for multiple inputs)
                  onnxmodelfile,             # where to save the model (can be a file or file-like object)
                  export_params=True,        # store the trained parameter weights inside the model file
                  opset_version=7,          # the ONNX version to export the model to
                  do_constant_folding=False,#True,  # whether to execute constant folding for optimization
                  input_names = ['input'],   # the model's input names
                  output_names = ['output'], # the model's output names
                  dynamic_axes={'input' : {0 : 'batch_size'},    # variable lenght axes
                                'output' : {0 : 'batch_size'}},
                  keep_initializers_as_inputs=True,
                  verbose=True)

Steps to reproduce

(Paste the commands you ran that produced the error.)

  1. Just execute the file with the code from the description

What have you tried to solve it?

Environment

Environment Information ``` ----------Python Info---------- Version : 3.8.5 Compiler : GCC 9.3.0 Build : ('default', 'Jan 27 2021 15:41:15') Arch : ('64bit', 'ELF') ------------Pip Info----------- Version : 21.1.1 Directory : /home/elena/.local/lib/python3.8/site-packages/pip ----------MXNet Info----------- Version : 1.8.0 Directory : /home/elena/.local/lib/python3.8/site-packages/mxnet Commit hash file "/home/elena/.local/lib/python3.8/site-packages/mxnet/COMMIT_HASH" not found. Not installed from pre-built package or built from source. Library : ['/home/elena/.local/lib/python3.8/site-packages/mxnet/libmxnet.so'] Build features: ✖ CUDA ✖ CUDNN ✖ NCCL ✖ CUDA_RTC ✖ TENSORRT ✔ CPU_SSE ✔ CPU_SSE2 ✔ CPU_SSE3 ✖ CPU_SSE4_1 ✖ CPU_SSE4_2 ✖ CPU_SSE4A ✖ CPU_AVX ✖ CPU_AVX2 ✔ OPENMP ✖ SSE ✖ F16C ✖ JEMALLOC ✔ BLAS_OPEN ✖ BLAS_ATLAS ✖ BLAS_MKL ✖ BLAS_APPLE ✔ LAPACK ✔ MKLDNN ✔ OPENCV ✖ CAFFE ✖ PROFILER ✔ DIST_KVSTORE ✖ CXX14 ✖ INT64_TENSOR_SIZE ✔ SIGNAL_HANDLER ✖ DEBUG ✖ TVM_OP ----------System Info---------- Platform : Linux-5.8.0-53-generic-x86_64-with-glibc2.29 system : Linux node : elena-ThinkPad-T490 release : 5.8.0-53-generic version : #60~20.04.1-Ubuntu SMP Thu May 6 09:52:46 UTC 2021 ----------Hardware Info---------- machine : x86_64 processor : x86_64 Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 39 bits physical, 48 bits virtual CPU(s): 1 On-line CPU(s) list: 0 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 142 Model name: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz Stepping: 12 CPU MHz: 1991.999 BogoMIPS: 3983.99 Hypervisor vendor: KVM Virtualization type: full L1d cache: 32 KiB L1i cache: 32 KiB L2 cache: 256 KiB L3 cache: 8 MiB NUMA node0 CPU(s): 0 Vulnerability Itlb multihit: KVM: Mitigation: VMX unsupported Vulnerability L1tf: Mitigation; PTE Inversion Vulnerability Mds: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown Vulnerability Meltdown: Mitigation; PTI Vulnerability Spec store bypass: Vulnerable Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Full generic retpoline, STIBP disabled, RSB filling Vulnerability Srbds: Unknown: Dependent on hypervisor status Vulnerability Tsx async abort: Not affected Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_ known_freq pni pclmulqdq monitor ssse3 cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase avx2 invpcid rds eed clflushopt flush_l1d ----------Network Test---------- Setting timeout: 10 Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0115 sec, LOAD: 0.5904 sec. Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0971 sec, LOAD: 0.1029 sec. Error open Gluon Tutorial(cn): https://zh.gluon.ai, , DNS finished in 0.14083647727966309 sec. Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0378 sec, LOAD: 1.1586 sec. Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0725 sec, LOAD: 0.4793 sec. Error open Conda: https://repo.continuum.io/pkgs/free/, HTTP Error 403: Forbidden, DNS finished in 5.180579423904419 sec. ----------Environment---------- ```
github-actions[bot] commented 3 years ago

Welcome to Apache MXNet (incubating)! We are on a mission to democratize AI, and we are glad that you are contributing to it by opening this issue. Please make sure to include all the relevant context, and one of the @apache/mxnet-committers will be here shortly. If you are interested in contributing to our project, let us know! Also, be sure to check out our guide on contributing to MXNet and our development guides wiki.

Paspartout commented 3 years ago

Might be a duplicate of https://github.com/apache/incubator-mxnet/issues/16590

pribadihcr commented 2 years ago

any solution?

gcunhase commented 1 year ago

Any updates?