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/09/04 07:02:30 UTC

[GitHub] [incubator-mxnet] Zheweiqiu commented on issue #16042: Error when calling get_backend_symbol

Zheweiqiu commented on issue #16042: Error when calling get_backend_symbol
URL: https://github.com/apache/incubator-mxnet/issues/16042#issuecomment-527771064
 
 
   > I mean you need "to reinstall mxnet library with tensorrt support". But if you can "successfully call mxnet.contrib.tensorrt", then I assume you're using the build that enable TensorRT backend. Then please try to add `os.environ['MXNET_USE_TENSORRT'] = '1'` in your scripts. Please read this documentation for full details:
   > https://github.com/apache/incubator-mxnet/blob/master/docs/tutorials/tensorrt/inference_with_trt.md
   Here is the result after I tried to follow the document
   My initial code: 
   ```
   sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch)
   if not use_trt:
           self.model = mx.mod.Module(symbol=sym, context=self.ctx, label_names = None)
           self.model.bind(data_shapes=[('data', (1, 3, image_size[0], image_size[1]))], for_training=False)
           self.model.set_params(arg_params, aux_params)
   else:
           print('------------ Using tensorrt for face detection --------------')
           trt_sym = sym.get_backend_symbol('TensorRT')
           mx.contrib.tensorrt.init_tensorrt_params(trt_sym, arg_params, aux_params)
           mx.contrib.tensorrt.set_use_fp16(False)
           self.model = trt_sym.simple_bind(ctx=self.ctx, data = (1,3,image_size[0], image_size[1]), grad_req='null', force_rebind=True)
           self.model.copy_params_from(arg_params, aux_params)
   
   ```
   I added one line according to your answer
   ```
   sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch)
   if not use_trt:
           self.model = mx.mod.Module(symbol=sym, context=self.ctx, label_names = None)
           self.model.bind(data_shapes=[('data', (1, 3, image_size[0], image_size[1]))], for_training=False)
           self.model.set_params(arg_params, aux_params)
   else:
           print('------------ Using tensorrt for face detection --------------')
           os.environ['MXNET_USE_TENSORRT'] = '1'
           trt_sym = sym.get_backend_symbol('TensorRT')
           mx.contrib.tensorrt.init_tensorrt_params(trt_sym, arg_params, aux_params)
           mx.contrib.tensorrt.set_use_fp16(False)
           self.model = trt_sym.simple_bind(ctx=self.ctx, data = (1,3,image_size[0], image_size[1]), grad_req='null', force_rebind=True)
           self.model.copy_params_from(arg_params, aux_params)
   
   ```
   But I still got the error:
   mxnet.base.MXNetError: [06:56:32] src/c_api/../operator/subgraph/subgraph_property.h:367: Check failed: it != prop_ptr_map_.end(): SubgraphProperty TensorRT is not found in SubgraphPropertyRegistry
   
   Then I tried alternative in that document and changed my code to:
   
   ```
   sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch)
   if not use_trt:
           self.model = mx.mod.Module(symbol=sym, context=self.ctx, label_names = None)
           self.model.bind(data_shapes=[('data', (1, 3, image_size[0], image_size[1]))], for_training=False)
           self.model.set_params(arg_params, aux_params)
   else:
           print('------------ Using tensorrt for face detection --------------')
           os.environ['MXNET_USE_TENSORRT'] = '1'
           arg_params.update(aux_params)
           all_params = dict([(k, v.as_in_context(self.ctx)) for k,v in arg_params.items()])
           self.model = mx.contrib.tensorrt.tensorrt_bind(sym, ctx=self.ctx, all_params=all_params, data=batch_shape, grad_req='null', force_rebind=True)
   
   ```
   
   But still got an errro:
   AttributeError: module 'mxnet.contrib.tensorrt' has no attribute 'tensorrt_bind'
   
   Below is my mxnet information:
   Name: mxnet-cu100mkl
   Version: 1.5.0
   Summary: MXNet is an ultra-scalable deep learning framework. This version uses CUDA-10.0 and MKLDNN.
   Home-page: https://github.com/apache/incubator-mxnet
   Author: UNKNOWN
   Author-email: UNKNOWN
   License: Apache 2.0
   Location: /opt/conda/lib/python3.7/site-packages
   Requires: numpy, requests, graphviz
   Required-by:
   
   Is that because I am using wrong version of mxnet?
   
   Appreciate for any help!

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