From e8549af8d4e126036f1c78dfea8d46c7c060b6de Mon Sep 17 00:00:00 2001 From: Sammy Tourani Date: Sun, 4 Oct 2026 00:40:54 -0400 Subject: [PATCH] #4866 - Fail trtexec engine build when buildSerializedNetworkToStream fails With --saveEngine, trtexec builds through IBuilder::buildSerializedNetworkToStream() but ignored its return value. When the build failed, trtexec still logged "Created engine with size: 0 MiB" and "Engine built in ... sec.", then exited on the assertion "Attempting to access an empty engine!" while saving the engine. Check the return value and fail with the same error that the buildSerializedNetwork() path reports. Signed-off-by: Sammy Tourani --- samples/common/sampleEngines.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/common/sampleEngines.cpp b/samples/common/sampleEngines.cpp index 0cd0a4c6b5..07b37b44a8 100644 --- a/samples/common/sampleEngines.cpp +++ b/samples/common/sampleEngines.cpp @@ -1299,7 +1299,8 @@ bool networkToSerializedEngine( { auto const engineFile = build.engine; FileStreamWriter writer(engineFile); - builder.buildSerializedNetworkToStream(network, config, writer); + SMP_RETVAL_IF_FALSE(builder.buildSerializedNetworkToStream(network, config, writer), + "Engine could not be created from network", false, err); auto const engineSize = writer.finalize(); std::vector streamEngine(engineSize, 0); std::ifstream reader(engineFile, std::ios::binary);