A .ansmodel reaching the GPU path went to ModelOptimizer, which knows one
way to open a model — unzip it — and failed on the first byte. Even past
that, the TensorRT engine only ever parsed an ONNX file, so the one thing
the format exists to prevent, a decrypted model on disk, was the only way
it could have run.
The builder now takes its bytes from memory when it has them. The path it
is given still names the plan that gets cached beside it, because a plan
is a built artefact and carries no model: the second run loads it and
never needs the ONNX at all. For a package the plan lands in the folder
the zip flow used, so a model converted from a zip reuses the plan that
zip already built.
OptimizeModelStr recognises a package and skips the unzip-and-optimise
leg entirely: the handle below it opens the package in memory and builds
the plan from the decrypted bytes, which is the same work by a shorter
road.
Still on the file path: the other TensorRT handlers (segmentation, pose,
classification). Only the YOLO detector reads a package today.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Verified on dual RTX 5080: 355/355 detections, both GPUs in round-robin,
zero CUDA errors. Requires TensorRT >= 10.16.1 in SharedCore (10.15.1 has
a Myelin l2cm crash when creating a context on a second Blackwell device).
1. blobFromGpuMats: thread_local GpuMat caches (tl_blob/tl_floatImg) were
device-blind — a pool thread warming GPU[1] then GPU[0] reused device-1
memory with a device-0 stream, causing an async illegal memory access
that poisoned every CUDA context (sticky 700). Track owning device and
rebuild the cache on device switch.
2. runInference: pool round-robin can dispatch to a slot on a different
GPU than the one the caller prepared inputs on. Detect foreign input
GpuMats via cudaPointerGetAttributes and migrate them through a pinned
host staging buffer (two-hop D2H+H2D; direct cross-device cudaMemcpy2D
is unsupported and GeForce has no P2P).
3. warmUp: now pins its own CUDA device before uploading dummy inputs and
returns success/failure; loadNetwork rejects engines whose warmup fails
so broken slots can never join the pool silently.
4. Blackwell builder workaround: setMaxAuxStreams(0) on SM 12.x plus an
.aux0 engine-cache suffix so pre-workaround caches rebuild.
Also: ANSFR-UnitTest gains --gpu N flag (sets CUDA_VISIBLE_DEVICES) for
single-GPU bisection, and rich diagnostics on input-copy failures.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>