Repository navigation
#4866 - Fail trtexec engine build when buildSerializedNetworkToStream fails - #4867
SammyTourani wants to merge 1 commit into
Conversation
…Stream 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 <sammytourani@gmail.com>
|
The assertion calls The actual defect is that two |
|
The failing op is b, h, w, w2 = cv.shape
self.cv = cv.reshape(b * h * w, 1, 1, w2)
self.cv_2x = F.avg_pool2d(self.cv, kernel_size=[1, 2]) # <-- fails hereThe pooled tensor is
1280 × 800 sits 1,536 below 2¹⁶ and builds; the next size up exceeds it and The Myelin error in the 11.3.0 log is consistent with that: No viable tactic for the fused node containing that pooling op. WorkaroundRewriting the pool as reshape + mean avoids the pooling layer and emits # before
self.cv_2x = F.avg_pool2d(self.cv, kernel_size=[1, 2])
# after - numerically identical
_n, _c, _h, _w2 = self.cv.shape
self.cv_2x = self.cv.reshape(_n, _c, _h, _w2 // 2, 2).mean(dim=-1)Verified bit-exact against All previously failing builds now succeed:
(11.3.0 builds are fp32 — no The patch changes only the Remaining questionIs the ~65,536 batch limit on pooling layers expected and documented? If it is a |
|
@SammyTourani You noted no GPU was available. We hit this on Jetson AGX Thor (sm_110), Same Error Code 10 from Happy to test a patched |
Fixes #4866
Related to #4866 (question 3, the "0 MiB engine" output). The engine build failure itself happens inside TensorRT and is
not addressed here.
With
--saveEngine, trtexec builds throughIBuilder::buildSerializedNetworkToStream()innetworkToSerializedEngine()(
samples/common/sampleEngines.cpp), but ignored theboolit returns. When the build failed, trtexec loggedCreated engine with size: 0 MiBandEngine built in ... sec.after the builder's error. It then exited onAssertion failure: false && "Attempting to access an empty engine!"while saving the engine.The return value is now checked with
SMP_RETVAL_IF_FALSE. The error message is the one thebuildSerializedNetwork()path in the same function already uses (
Engine could not be created from network). A failed build now goes throughtrtexec's normal failure path:
The exit status was already non-zero before this change, because the assertion calls
exit(EXIT_FAILURE). What changesis that trtexec no longer reports a 0 MiB engine as built and no longer ends on an internal assertion. Successful builds
are unaffected.
Verification
No GPU was available, so this was not tested against a real TensorRT build failure. Instead I built
samples/commonwithclang (C++20,
TRT_BUILD_ONNX_PARSER=1) against fake builder, network, config and ONNX parser objects. A small driver,not part of this PR, calls
sample::getEngineBuildEnv()with the optionstrtexec --onnx=model.onnx --saveEngine=<file>sets, and handles a failure the same way trtexec's
main()does. The fakebuildSerializedNetworkToStream()works inone of two modes:
fail: reportsError Code 10through the error recorder and returnsfalsewithout writing anything, as in the logattached to Engine build failure of TensorRT 10.14.1 and 11.3.0 when running S2M2 stereo matching above ~1 MPix input on Jetson AGX Thor (sm_110) #4866.
succeed: writes a 3 MiB plan and returnstrue.The driver was built once from
98adec8(before) and once from this commit (after). Log timestamps are removed below;the output is otherwise verbatim.
Command:
build-before/harness fail before-fail.engineResult:
Command:
build-after/harness fail after-fail.engineResult:
Command:
build-before/harness succeed before-succeed.engineandbuild-after/harness succeed after-succeed.engineResult: identical before and after. Both print
Created engine with size: 3.00002 MiBandEngine built in ... sec.,save a 3145745-byte engine file, and exit with status 0.
Command:
build-tests-before/trt_samples_common_testandbuild-tests-after/trt_samples_common_test. This is thesamples/commongtest suite fromsamples/common/CMakeLists.txt, built the same way.Result:
[==========] 81 tests from 12 test suites ran./[ PASSED ] 81 tests.both before and after. None of thesetests exercise the build path in
sampleEngines.cpp, and the gtest binary does not linkgetEngineBuildEnvat all. Thisrun only shows that nothing else in
samples/commonbroke.clang-format -style=file(23.1.2) reports no changes on the edited lines.