tensorflow/tensorrt

int8 precision tf model converting to tftrt

Opened this issue · 0 comments

image_tensor = graph.get_tensor_by_name('wpf:0')
calib_graph = trt.create_inference_graph(
input_graph_def=graph_def,
outputs=output_names,
max_batch_size=1,
minimum_segment_size=4,
is_dynamic_op=True,
maximum_cached_engines=3,
max_workspace_size_bytes=trt.DEFAULT_TRT_MAX_WORKSPACE_SIZE_BYTES,
precision_mode='INT8'
)

		a,b,c,d = tf.import_graph_def(calib_graph, input_map={"wpf": image_tensor},
											 return_elements=output_names, name="")
		a, b, c, d = sess.run([a,b,c,d], feed_dict={image_tensor: [cv2.resize(cv2.imread("../images/1.jpg"),(608,600))]})


		trt_graph = trt.calib_graph_to_infer_graph(calib_graph)

2020-10-12 06:59:42.707103: E tensorflow/core/grappler/optimizers/meta_optimizer.cc:586] function_optimizer failed: Invalid argument: Invalid loop structure: Loop "BatchMultiClassNonMaxSuppression/map/while/while_context" has more than one LoopCond node: {{node BatchMultiClassNonMaxSuppression/map/while/LoopCond_1}} and {{node BatchMultiClassNonMaxSuppression/map/while/LoopCond}}. This is an internal bug, please file a bug report with instructions on how to reproduce the error.
2020-10-12 06:59:43.493964: E tensorflow/core/grappler/optimizers/meta_optimizer.cc:586] function_optimizer failed: Invalid argument: Invalid loop structure: Loop "BatchMultiClassNonMaxSuppression/map/while/while_context" has more than one LoopCond node: {{node BatchMultiClassNonMaxSuppression/map/while/LoopCond}} and {{node BatchMultiClassNonMaxSuppression/map/while/LoopCond_1}}. This is an internal bug, please file a bug report with instructions on how to reproduce the error.
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 1365, in _do_call
return fn(*args)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 1350, in _run_fn
target_list, run_metadata)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 1443, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Invalid loop structure: Loop "BatchMultiClassNonMaxSuppression/map/while/while_context" has more than one LoopCond node: {{node BatchMultiClassNonMaxSuppression/map/while/LoopCond}} and {{node BatchMultiClassNonMaxSuppression/map/while/LoopCond_1}}. This is an internal bug, please file a bug report with instructions on how to reproduce the error.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/inspur/wpf/objec_dec_opt/dianwu_loulan/models/graph_info.py", line 440, in
trt_convert(args.model_path)
File "/home/inspur/wpf/objec_dec_opt/dianwu_loulan/models/graph_info.py", line 220, in trt_convert
a, b, c, d = sess.run([a,b,c,d], feed_dict={image_tensor: [cv2.resize(cv2.imread("../images/1.jpg"),(608,600))]})
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 956, in run
run_metadata_ptr)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 1180, in _run
feed_dict_tensor, options, run_metadata)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 1359, in _do_run
run_metadata)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/client/session.py", line 1384, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Invalid loop structure: Loop "BatchMultiClassNonMaxSuppression/map/while/while_context" has more than one LoopCond node: node BatchMultiClassNonMaxSuppression/map/while/LoopCond (defined at usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py:1748) and node BatchMultiClassNonMaxSuppression/map/while/LoopCond_1 (defined at usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py:1748) . This is an internal bug, please file a bug report with instructions on how to reproduce the error.