From 42afcfc2be7d6b7e8f5fc7e5357f851b207daf9d Mon Sep 17 00:00:00 2001 From: gh-underfoot581 <313842205+gh-underfoot581@users.noreply.github.com> Date: Mon, 31 Aug 2026 21:40:54 +1000 Subject: [PATCH] fix: show the export output when a TensorRT export fails The export subprocess is started with stderr=subprocess.STDOUT, so the stderr handed back is always empty and every failure surfaces as "Export failed:" with nothing after it. Report stdout instead, which carries the merged output. The JSON branch gets the same treatment: the export script already puts a traceback in its result, it was just never read. --- application/utils/tensorrt_compiler.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/application/utils/tensorrt_compiler.py b/application/utils/tensorrt_compiler.py index baac539c..7743a1a5 100644 --- a/application/utils/tensorrt_compiler.py +++ b/application/utils/tensorrt_compiler.py @@ -429,7 +429,8 @@ def compile_yolo_to_tensorrt( stdout, stderr = self._run_export_subprocess(export_script, pt_model_path, output_dir) if self._export_process.returncode != 0: - raise TensorRTCompilerError(f"Export failed: {stderr}") + # stderr is always empty (merged into stdout via stderr=STDOUT) + raise TensorRTCompilerError(f"Export failed: {stdout}") try: # Try to find JSON in the output (may be mixed with other text) @@ -439,7 +440,11 @@ def compile_yolo_to_tensorrt( json_str = stdout[json_start:json_end] result = json.loads(json_str) if not result.get('success'): - raise TensorRTCompilerError(f"Export failed: {result.get('error', 'Unknown error')}") + error_msg = result.get('error', 'Unknown error') + tb = result.get('traceback', '') + if tb: + error_msg = f"{error_msg}\n\nTraceback:\n{tb}" + raise TensorRTCompilerError(f"Export failed: {error_msg}") # Move the created engine file to the expected location created_engine = result.get('engine_file')