leezu commented on issue #18765:
URL: 
https://github.com/apache/incubator-mxnet/issues/18765#issuecomment-662047865


   Simpler reproducible example for latest master:
   
   ```
   import mxnet as mx
   from mxnet import gluon
   from mxnet.gluon import nn
   
   a = mx.nd.random.uniform(shape=(1,3,224,224))
   
   backbone = gluon.model_zoo.vision.resnet18_v1()
   backbone.initialize()
   backbone.hybridize()
   
   backbone(a)
   
   # Alternative:
   # backbone.reset_ctx(mx.gpu(0))
   # b = backbone(a.as_in_context(mx.gpu(0)))
   # print([x.shape for x in b])
   
   sym_file, params_file = backbone.export('/tmp/model')
   
   f = gluon.SymbolBlock.imports(sym_file, 'data', params_file)
   f.reset_ctx(mx.gpu(0))
   b = f(a.as_in_context(mx.gpu(0)))
   print([x.shape for x in b])
   ```
   
   It fails with
   
   ```
   [18:59:34] ../src/storage/storage.cc:198: Using Pooled (Naive) 
StorageManager for CPU
   /home/ubuntu/src/mxnet-master/python/mxnet/gluon/block.py:1723: UserWarning: 
Cannot decide type for the following arguments. Consider providing them as 
input:
           data: None
     input_sym_arg_type = in_param.infer_type()[0]
   [18:59:37] ../src/storage/storage.cc:198: Using Pooled (Naive) 
StorageManager for GPU
   [(1000,)]
   [18:59:38] ../src/operator/nn/./cudnn/./cudnn_algoreg-inl.h:97: Running 
performance tests to find the best convolution algorithm, this can take a 
while... (set the environment variable MXNET_CUDNN_AUTOTUNE_DEFAULT to 0 to 
disable)
   
   Segmentation fault: 11
   
   zsh: abort (core dumped)  python3 symbolblockbug.py
   ```
   
   
   However, the following will work:
   ```
   
   import mxnet as mx
   from mxnet import gluon
   from mxnet.gluon import nn
   
   a = mx.nd.random.uniform(shape=(1,3,224,224))
   
   backbone = gluon.model_zoo.vision.resnet18_v1()
   backbone.initialize()
   backbone.hybridize()
   
   # backbone(a)
   
   # Alternative:
   backbone.reset_ctx(mx.gpu(0))
   b = backbone(a.as_in_context(mx.gpu(0)))
   print([x.shape for x in b])
   
   sym_file, params_file = backbone.export('/tmp/model')
   
   f = gluon.SymbolBlock.imports(sym_file, 'data', params_file)
   f.reset_ctx(mx.gpu(0))
   b = f(a.as_in_context(mx.gpu(0)))
   print([x.shape for x in b])
   ```


----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to