ptrblck:

torch.cuda.synchronize()


Your point is correct, but regardless, the overall code was previously taking unusually long.
After I wrapped my code with torch.cuda.synchronize() things got normal. I assume the problem previously was that a long buffer of these calls was somehow forming and ruining everything. Am I correct?