[Bug Report] TF-TRT conversion fails silently on deeprec2402-gpu-cu116 image
### Environment
- Docker Image: alideeprec/deeprec-release:deeprec2402-gpu-py38-cu116-ubuntu20.04
- TensorRT-8.2.1.8
### Problem Description
I am trying to optimize a model using TF-TRT with FP16 precision in the official deeprec2402 environment. The conversion process completes without any errors, but it produces no TRTEngineOp in the resulting graph. This happens even with minimum_segment_size=1 and max_batch_size=128.
### Reproducible Test Case
To isolate the problem, I created a minimal graph containing only a ConcatV2 layer followed by a Dense layer. This minimal test case also fails to convert, which proves the issue is with the framework's core TF-TRT integration and not my specific model.
Here is the Python script for the minimal test case:
```python
import tensorflow as tf
from tensorflow.python.framework import graph_util
from tensorflow.python.framework import graph_io
from tensorflow.contrib.tensorrt import trt_convert as trt
import os
def create_and_test_minimal_graph():
graph = tf.Graph()
with graph.as_default():
input_1 = tf.placeholder(tf.float32, shape=[None, 300], name='input_1')
input_2 = tf.placeholder(tf.float32, shape=[None, 500], name='input_2')
input_3 = tf.placeholder(tf.float32, shape=[None, 171], name='input_3')
concatenated_tensor = tf.concat([input_1, input_2, input_3], axis=1, name='the_concat')
dense_output = tf.layers.dense(inputs=concatenated_tensor, units=256, activation=tf.nn.relu, name='the_dense')
output_node = tf.identity(dense_output, name='output')
frozen_graph_path = './minimal_frozen.pb'
trt_graph_path = './minimal_trt.pb'
output_node_names = 'output'
with tf.Session(graph=graph) as sess:
sess.run(tf.global_variables_initializer())
frozen_graph_def = graph_util.convert_variables_to_constants(
sess,
sess.graph_def,
output_node_names.split(',')
)
with open(frozen_graph_path, 'wb') as f:
f.write(frozen_graph_def.SerializeToString())
print(f"Minimal graph frozen to: {frozen_graph_path}")
with tf.gfile.GFile(frozen_graph_path, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
print("\n--- Starting TRT Conversion for Minimal Graph ---")
converter = trt.TrtGraphConverter(
input_graph_def=graph_def,
nodes_blacklist=[output_node_names],
max_batch_size=128,
precision_mode='FP16',
minimum_segment_size=2
)
trt_graph_def = converter.convert()
if trt_graph_def is None:
print("!!! CONVERSION FAILED: converter.convert() returned None.")
return
num_trt_nodes = len([n for n in trt_graph_def.node if str(n.op) == 'TRTEngineOp'])
print(f"Conversion finished. Number of TRTEngineOp nodes found: {num_trt_nodes}")
if num_trt_nodes > 0:
print(">>> SUCCESS! The minimal graph was converted successfully.")
graph_io.write_graph(trt_graph_def, os.path.dirname(trt_graph_path), os.path.basename(trt_graph_path), as_text=False)
print(f"Minimal TRT graph saved to: {trt_graph_path}")
else:
print(">>> FAILURE! The minimal graph could NOT be converted. The problem lies within the ConcatV2->Dense structure itself.")
if __name__ == '__main__':
create_and_test_minimal_graph()`
```
### Question
Is TF-TRT V1 conversion officially supported in this TF 1.15 + CUDA 11.6 custom environment?
If it is supported, are there any special parameters or steps required to make it work?
If it is not supported, are there any alternative model optimization or acceleration tools recommended for DeepRec?
Thank you!
关闭于 2025-08-01 0 条评论