Add DLPack debug logging to diagnose zero-copy
Some checks are pending
GPU Worker CI/CD / test (push) Waiting to run
GPU Worker CI/CD / deploy (push) Blocked by required conditions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-04 02:06:19 +00:00
parent 36c4afeb84
commit 1cb9c3ac8a

View File

@@ -336,9 +336,16 @@ class GPUVideoSource:
# This keeps the frame on GPU without any CPU transfer
try:
gpu_frame = cp.from_dlpack(frame_tensor)
# Log success once per source
if not getattr(self, '_dlpack_logged', False):
print(f"[GPUVideoSource] DLPack zero-copy SUCCESS - frames stay on GPU", file=sys.stderr)
self._dlpack_logged = True
return GPUFrame(gpu_frame, on_gpu=True)
except Exception:
except Exception as dlpack_err:
# Fallback: convert via numpy (involves CPU copy)
if not getattr(self, '_dlpack_fail_logged', False):
print(f"[GPUVideoSource] DLPack FAILED ({dlpack_err}), using CPU copy fallback", file=sys.stderr)
self._dlpack_fail_logged = True
frame_np = frame_tensor.asnumpy()
return GPUFrame(frame_np, on_gpu=True)
else: