ValueError: shared_buffer in simple_bind must be dict or None

Hi All,

I am new to MxNet, Just trained my yolo3 network and doing forward pass similar to below demo code

====================================================== = model_zoo.get_model(model_name, pretrained=False, classes=(“cat”, “dog”))

cls_ids, scores, bboxs =


Now I want to move it to TensorRt by going through

Now I am clueless on how to get below code working to get TensortRT executor to bind to my model

executor = mx.contrib.tensorrt.tensorrt_bind(sym, ctx=mx.gpu(0), all_params=all_params,
data=batch_shape, grad_req=‘null’, force_rebind=True)

y_gen = executor.forward(is_train=False, data=input)


Missing parts in how to get the “sym”( The symbol configuration of computation network.) and all_params etc arguments to create the executor

One change I tried to do is as below

    self.executor = mx.contrib.tensorrt.tensorrt_bind(, ctx=mx.gpu(0), all_params=params,
                                         data=(1,3,416,416), grad_req='null', force_rebind=True)


But got error
AttributeError: ‘YOLOV3’ object has no attribute ‘simple_bind’

Thanks for help !!!

Pallab Sarkar

tensorrt_bind is expecting a Symbol, but you give it a HybridBlock. If you want to use Gluon Model Zoo, then you have to convert the HybridBlock into a Symbol. E.g.:'model')
sym = mx.sym.load('model.json')

self.executor = mx.contrib.tensorrt.tensorrt_bind(sym, ctx=mx.gpu(0), all_params=params,
                                         data=(1,3,416,416), grad_req='null', force_rebind=True)

Apart from that: you also need to set the environment variable MXNET_USE_TENSORRT=1

1 Like

Thanks NRauschmayr,

I am successfully able to convert HybridBlock into a Symbol. by below code
sym = mx.sym.load(self.model_name+"-symbol.json")
self.executor = mx.contrib.tensorrt.tensorrt_bind(sym, ctx=mx.gpu(0), all_params=self.params,data=(1,3,416,416), grad_req=‘null’, force_rebind=True)

But now getting one more new error as below
ValueError: shared_buffer in simple_bind must be dict or None

If anybody can guide me further on resolving the issue , It will really helpful.

Pallab Sarkar

Can you check if self.params is a dictionary containing your model parameters?

Hi ,
Thanks for your inputs,
In my case self.param is a string , which is path to my model.param file ,
I think I need to somehow extract param dictionary from this .param file and pass it to bind API call.
Please let me know your view on this !!


Ok that explains the error: self.param needs to be a dictionary of model parameters. You could use model.load_parameters('model.param') to load the parameters into your model and then model.get_parameters() to retrieve the dictionaries for arg_params and aux_params.
tensorrt_bind expects a merged dictionary, so can do the following:
all_params = dict([(k, v.as_in_context(mx.gpu(0))) for k, v in arg_params.items()])