Why set cuda(non_blocking=False) for target variables?

Non-Blocking allows you to overlap compute and memory transfer to the GPU. The reason you can set the target as non-blocking is so you can overlap the compute of the model and the transfer of the ground-truth. If you set the input to also non-blocking, it would yield no benefit due to the fact that the model has a dependency on the input data.

Pinned Memory allows the non-blocking calls to actually be non-blocking.

8 Likes