Cuda illegal memory error

I have cuda illegal memory error. It happen randomly aftter 7000 until 15000 iteration… im confuce about this error. I was try to make all operation

Like

Torch.ones

Torch zeros

Into variable

It reduce the number of error

How i solve this problem?

Could you post the stack trace please?

this is my error,

Could you post a minimal code snippet to reproduce this issue?