You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/03/28 14:26:39 UTC

[GitHub] [incubator-mxnet] saptarshim-dal opened a new issue #14551: Simple bind error while inferencing from an onnx model using mxnet on AWS EI

saptarshim-dal opened a new issue #14551: Simple bind error while inferencing from an onnx model using mxnet on AWS EI
URL: https://github.com/apache/incubator-mxnet/issues/14551
 
 
   ## Description
   I am trying to infer from an onnx model using MXNet on AWS EI and encountering the following error. The code is working as expected while using MXNet 1.2.1 and onnx 1.1.2. I am a noob in ML and have no clue about the error I am getting.
   
   ## Environment info (Required)
   AWS c5.xlarge EC2 instance
   AWS eia1.large EI accelerator
   Python 2.7
   amazonei-mxnet 1.3.0
   onnx 1.2.1
   
   ## Code
   import mxnet as mx
   from mxnet.contrib import onnx as onnx_mxnet
   import numpy as np
   from collections import namedtuple
   from PIL import Image
   
   image = Image.open('./Test_Images/Sadness/image0001582.jpgff.jpg')
   image = image.resize((227, 227))
   image_data = np.asarray(image, dtype=np.float32) - 128
   image_data = np.ascontiguousarray(np.rollaxis(image_data, 2))
   image_data = image_data[np.newaxis, :, :, :].astype(np.float32)
   print(image_data.shape)
   
   data_names = ['data']
   Batch = namedtuple('Batch', data_names)
   
   ctx = mx.eia()
   
   sym, arg, aux = onnx_mxnet.import_model('./Models/facenet1001.onnx')
   mod = mx.mod.Module(symbol=sym, data_names=data_names, context=ctx, label_names=None)
   mod.bind(for_training=False, data_shapes=[(data_names[0],image_data.shape)], label_shapes=None)
   mod.set_params(arg_params=arg, aux_params=aux, allow_missing=True, allow_extra=True)
   
   mod.forward(Batch([mx.nd.array(image_data)]))
   predictions = mod.get_outputs()[0].asnumpy()
   predictions = predictions[0].tolist()
   
   zipb_object = zip(['Anger', 'Confusion', 'Contempt', 'Disgust', 'Fear', 'Happiness', 'Neutral', 'NoFace', 'Sadness', 'Surprise'], predictions)
   prediction_dictionary = dict(zipb_object)
   
   print(prediction_dictionary)
   
   ## Error Message:
   Using Amazon Elastic Inference Client Library Version: 1.2.12
   Number of Elastic Inference Accelerators Available: 1
   Elastic Inference Accelerator ID: eia-cb0a16c893874b43855dc0e0d2aacab7
   Elastic Inference Accelerator Type: eia1.large
   
   Traceback (most recent call last):
     File "Inferrer_GPU_Only.py", line 58, in <module>
       mod.bind(for_training=False, data_shapes=[(data_names[0],image_data.shape)], label_shapes=None)
     File "/home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/site-packages/mxnet/module/module.py", line 434, in bind
       state_names=self._state_names)
     File "/home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/site-packages/mxnet/module/executor_group.py", line 279, in __init__
       self.bind_exec(data_shapes, label_shapes, shared_group)
     File "/home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/site-packages/mxnet/module/executor_group.py", line 382, in bind_exec
       shared_group))
     File "/home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/site-packages/mxnet/module/executor_group.py", line 669, in _bind_ith_exec
       shared_buffer=shared_data_arrays, **input_shapes)
     File "/home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/site-packages/mxnet/symbol/symbol.py", line 1529, in simple_bind
       raise RuntimeError(error_msg)
   RuntimeError: simple_bind error. Arguments:
   data: (1, 3, 227, 227)
   Error in operator broadcast_sub0: [14:16:11] src/operator/tensor/./elemwise_binary_broadcast_op.h:68: Check failed: l == 1 || r == 1 operands could not be broadcast together with shapes [1,3,227,227] [1,154587,1,1]
   
   Stack trace returned 10 entries:
   [bt] (0) /home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(dmlc::StackTrace()+0x44) [0x7ff5f791a394]
   [bt] (1) /home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x21) [0x7ff5f791a771]
   [bt] (2) /home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::op::BinaryBroadcastShape(nnvm::NodeAttrs const&, std::vector<nnvm::TShape, std::allocator<nnvm::TShape> >*, std::vector<nnvm::TShape, std::allocator<nnvm::TShape> >*)+0xbf7) [0x7ff5f855d4b7]
   [bt] (3) /home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x2ff9b4a) [0x7ff5fa300b4a]
   [bt] (4) /home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::exec::InferShape(nnvm::Graph&&, std::vector<nnvm::TShape, std::allocator<nnvm::TShape> >&&, std::string const&)+0x150d) [0x7ff5fa30349d]
   [bt] (5) /home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::exec::GraphExecutor::Init(nnvm::Symbol, mxnet::Context const&, std::map<std::string, mxnet::Context, std::less<std::string>, std::allocator<std::pair<std::string const, mxnet::Context> > > const&, std::vector<mxnet::Context, std::allocator<mxnet::Context> > const&, std::vector<mxnet::Context, std::allocator<mxnet::Context> > const&, std::vector<mxnet::Context, std::allocator<mxnet::Context> > const&, std::unordered_map<std::string, nnvm::TShape, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, nnvm::TShape> > > const&, std::unordered_map<std::string, int, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, int> > > const&, std::unordered_map<std::string, int, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, int> > > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, std::unordered_set<std::string, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::string> > const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> >*, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> >*, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> >*, std::unordered_map<std::string, mxnet::NDArray, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, mxnet::NDArray> > >*, mxnet::Executor*, std::unordered_map<nnvm::NodeEntry, mxnet::NDArray, nnvm::NodeEntryHash, nnvm::NodeEntryEqual, std::allocator<std::pair<nnvm::NodeEntry const, mxnet::NDArray> > > const&)+0x3fd) [0x7ff5fa2dff2d]
   [bt] (6) /home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(mxnet::Executor::SimpleBind(nnvm::Symbol, mxnet::Context const&, std::map<std::string, mxnet::Context, std::less<std::string>, std::allocator<std::pair<std::string const, mxnet::Context> > > const&, std::vector<mxnet::Context, std::allocator<mxnet::Context> > const&, std::vector<mxnet::Context, std::allocator<mxnet::Context> > const&, std::vector<mxnet::Context, std::allocator<mxnet::Context> > const&, std::unordered_map<std::string, nnvm::TShape, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, nnvm::TShape> > > const&, std::unordered_map<std::string, int, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, int> > > const&, std::unordered_map<std::string, int, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, int> > > const&, std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> > const&, std::unordered_set<std::string, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::string> > const&, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> >*, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> >*, std::vector<mxnet::NDArray, std::allocator<mxnet::NDArray> >*, std::unordered_map<std::string, mxnet::NDArray, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, mxnet::NDArray> > >*, mxnet::Executor*)+0x2a5) [0x7ff5fa2e2045]
   [bt] (7) /home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/site-packages/mxnet/libmxnet.so(MXExecutorSimpleBind+0x23b4) [0x7ff5fa20c814]
   [bt] (8) /home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/lib-dynload/../../libffi.so.6(ffi_call_unix64+0x4c) [0x7ff602024ec0]
   [bt] (9) /home/ubuntu/anaconda3/envs/amazonei_mxnet_p27/lib/python2.7/lib-dynload/../../libffi.so.6(ffi_call+0x22d) [0x7ff60202487d]

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services