mxnet转onnx 之 onnx_mxnet.export_model失败原因

mxnet模型转换onnx折腾了很久,终于搞清楚失败原因

转换代码参考: https://github.com/onnx/tutorials/blob/master/tutorials/MXNetONNXExport.ipynb

 

一开始的环境:

  • windows 10
  • visual studio 2019
  • python37
  • mxnet==1.4.1

pip install onnx 安装的是最新的1.6.0版本 

运行到 “onnx_mxnet.export_model” 这一句代码的时候 提示invalid *** array,然后就不能转换了

mxnet.base.MXNetError: [10:25:05] C:\Jenkins\workspace\mxnet-tag\mxnet\src\ndarray\ndarray.cc:1805: Check failed: fi->Read(data) Invalid NDArray file format

好嘛, 我查资料说是onnx1.2.1版本可以转换成功,(也有说1.2.2,1.3.0都可以的) pip install onnx==1.2.1竟然失败

好,我源码安装,参考https://github.com/onnx/onnx/readme.md 一样失败 源码折腾了近两天啊

 

要疯了

 

终于找到资料这么说的:

Hi thanks for reporting this. It looks like you are build onnx for python2.7 using vc9.0. We highly suggested you switch to python3.5/6 on Windows because 1)onnx is developed with c++11 standard so dated VC cannot support some functions. 2) if using new VC (can do it in a conda3.5/6 with a py2.7 environment), there could be potential CRT libs mismatch in later uses or development (python 2.7 on windows is made with dated VC). it may cause more problem later.

这个人的问题(https://github.com/onnx/onnx/issues/936)跟我的不太一样,但是它提醒了我,我的vc版本和python版本过高

 

更新后的环境:

  • windows 10
  • visual studio 2017
  • python36
  • mxnet==1.4.1
  • onnx==1.2.1  (pip install onnx==1.2.1)

安装成功了

 

运行提示:

[10:20:49] C:\Jenkins\workspace\mxnet-tag\mxnet\src\ndarray\ndarray.cc:1805: Check failed: fi->Read(data) Invalid NDArray file format

错误一样

 

 

你可能感兴趣的:(onnx,网状模型)