Hi,
This can happen for several reasons. If it happens after a few iteration, this is most likely that you are increasing your GPU memory needs from one iteration to the other, for example if you append to a list whole frames of the video at every iteration of the loop.
Can you give more details on what you’re doing?