If you’re using TensorRT in Python within a GStreamer pipeline loaded via PyGObject, watch out for a nasty crash when iterating over I/O tensor shapes.
The usual way—just converting trt.Dims to a tuple—works fine in plain scripts but blows up at runtime with no traceback inside GStreamer plugins. It’s a subtle bug tied to how PyGObject hooks into the allocator and interacts with Pybind11 objects.
The fix is simple but easy to miss: avoid using `tuple(dims)` directly. Instead, iterate safely with an index-based loop, like `tuple(dims[i] for i in range(len(dims)))`.
Has anyone else hit this? Would love to hear if you found other gotchas like this when bridging native libs and Python frameworks.
#MachineLearning #TensorRT #PythonInterop #GStreamer #PyGObject #GPUComputing
