Menu

Tracing a 13x PyTorch Slowdown to a Hidden NumPy Synchronization

DEV Community: pytorch·Ingero Team·6 months ago
#z0ZFA4vY
#dev#class#code#numpy#ingero
Reading 0:00
15s threshold

TL;DR: A .cpu().numpy() call buried inside a forward pass was forcing a full CPU-GPU synchronization on every batch, every loop iteration. The GPU would finish its work in milliseconds, then sit idle for ~2 seconds waiting for Python and NumPy to catch…

Anonymous readers can preview up to 1024 characters here. Log in to unlock the full article once ingest succeeds.