waytrue17 opened a new issue #20691:
URL: https://github.com/apache/incubator-mxnet/issues/20691


   ## Description
   When a model contains `concat`, `slice_axis` and `broadcast_lesser_equal`, 
it fails the backward pass with segmentation fault. It only failed with 
non-hybridized model. Tested on MXNet 1.8.0
   ### Error Message
   ```
   Thread 1 "python" received signal SIGSEGV, Segmentation fault.
   0x00007ffdd132e401 in mxnet::imperative::SetDependency(nnvm::NodeAttrs 
const&, mxnet::Context const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::engine::Var*, 
std::allocator<mxnet::engine::Var*> >*, std::vector<mxnet::engine::Var*, 
std::allocator<mxnet::engine::Var*> >*, std::vector<mxnet::Resource, 
std::allocator<mxnet::Resource> >*, std::vector<unsigned int, 
std::allocator<unsigned int> >*, mxnet::DispatchMode) ()
      from /home/ubuntu/workspace/mxnet/python/mxnet/../../build/libmxnet.so
   (gdb) bt
   #0  0x00007ffdd132e401 in mxnet::imperative::SetDependency(nnvm::NodeAttrs 
const&, mxnet::Context const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::engine::Var*, 
std::allocator<mxnet::engine::Var*> >*, std::vector<mxnet::engine::Var*, 
std::allocator<mxnet::engine::Var*> >*, std::vector<mxnet::Resource, 
std::allocator<mxnet::Resource> >*, std::vector<unsigned int, 
std::allocator<unsigned int> >*, mxnet::DispatchMode) ()
       at /home/ubuntu/workspace/mxnet/python/mxnet/../../build/libmxnet.so
   #1  0x00007ffdd1317050 in mxnet::Imperative::InvokeOp(mxnet::Context const&, 
nnvm::NodeAttrs const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::OpReqType, 
std::allocator<mxnet::OpReqType> > const&, mxnet::DispatchMode, 
mxnet::OpStatePtr) ()
       at /home/ubuntu/workspace/mxnet/python/mxnet/../../build/libmxnet.so
   #2  0x00007ffdd132fae7 in std::_Function_handler<void (mxnet::OpStatePtr 
const&), mxnet::imperative::RunGraph(bool, nnvm::IndexedGraph const&, 
std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, unsigned 
long, unsigned long, std::vector<mxnet::OpReqType, 
std::allocator<mxnet::OpReqType> >&&, std::vector<unsigned int, 
std::allocator<unsigned int> >&&, std::vector<mxnet::OpStatePtr, 
std::allocator<mxnet::OpStatePtr> >*, std::vector<mxnet::DispatchMode, 
std::allocator<mxnet::DispatchMode> > const&, bool, std::vector<mxnet::TShape, 
std::allocator<mxnet::TShape> >*, std::function<void (char const*, char const*, 
void*)> const&, bool)::{lambda(mxnet::OpStatePtr 
const&)#1}>::_M_invoke(std::_Any_data const&, mxnet::OpStatePtr const&) ()
       at /home/ubuntu/workspace/mxnet/python/mxnet/../../build/libmxnet.so
   #3  0x00007ffdd132fe62 in (anonymous 
namespace)::InvokeOperator(nnvm::IndexedGraph const&, int, bool, 
std::vector<mxnet::NDArray*, std::allocator<mxnet::NDArray*> > const&, 
mxnet::Context, std::vector<mxnet::OpStatePtr, 
std::allocator<mxnet::OpStatePtr> >*, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::OpReqType, 
std::allocator<mxnet::OpReqType> >*, std::vector<unsigned int, 
std::allocator<unsigned int> >*, std::function<void (mxnet::OpStatePtr 
const&)>) () at 
/home/ubuntu/workspace/mxnet/python/mxnet/../../build/libmxnet.so
   #4  0x00007ffdd1331227 in mxnet::imperative::RunGraph(bool, 
nnvm::IndexedGraph const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, unsigned long, unsigned long, 
std::vector<mxnet::OpReqType, std::allocator<mxnet::OpReqType> >&&, 
std::vector<unsigned int, std::allocator<unsigned int> >&&, 
std::vector<mxnet::OpStatePtr, std::allocator<mxnet::OpStatePtr> >*, 
std::vector<mxnet::DispatchMode, std::allocator<mxnet::DispatchMode> > const&, 
bool, std::vector<mxnet::TShape, std::allocator<mxnet::TShape> >*, 
std::function<void (char const*, char const*, void*)> const&, bool) () at 
/home/ubuntu/workspace/mxnet/python/mxnet/../../build/libmxnet.so
   #5  0x00007ffdd131ebd3 in 
mxnet::Imperative::Backward(std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, std::vector<mxnet::NDArray*, 
std::allocator<mxnet::NDArray*> > const&, bool, bool, bool) () at 
/home/ubuntu/workspace/mxnet/python/mxnet/../../build/libmxnet.so
   #6  0x00007ffdd11a1e3f in MXAutogradBackwardEx () at 
/home/ubuntu/workspace/mxnet/python/mxnet/../../build/libmxnet.so
   ```
   ## To Reproduce
   ```
   import mxnet as mx
   from mxnet.gluon import HybridBlock
   
   class _TestBlock(HybridBlock):
       def __init__(self):
           super(_TestBlock, self).__init__()
   
       def hybrid_forward(self, F, x, y):
           x = F.concat(x, x, dim=-1)
           x = F.slice_axis(x, axis=-1, begin=0, end=-1)
           return F.broadcast_lesser_equal(x, y)
   
   if __name__ == '__main__':
       block = _TestBlock()
       # block.hybridize() # hybridize works
   
       x = mx.nd.ones([32, 500, 4])
       y = mx.nd.ones([32, 500, 1])
       x.attach_grad()
       y.attach_grad()
   
       with mx.autograd.record():
           result = block(x, y)
           # block.export('partitioned')
       result.backward()
   
   print(result)
   ```
   
   ### Steps to reproduce
   (Paste the commands you ran that produced the error.)
   
   1. pip3 install mxnet==1.8.0.post0
   2. run the script
   
   ## What have you tried to solve it?
   
   ## Environment
   
   ***We recommend using our script for collecting the diagnostic information 
with the following command***
   `curl --retry 10 -s 
https://raw.githubusercontent.com/apache/incubator-mxnet/master/tools/diagnose.py
 | python3`
   
   <details>
   <summary>Environment Information</summary>
   
   ```
   # Paste the diagnose.py command output here
   ```
   
   </details>
   


-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@mxnet.apache.org
For additional commands, e-mail: issues-h...@mxnet.apache.org

Reply via email to