I think it’s expected that you would run out of memory, if you are using an infinite loop and allocate larger tensors in each iteration.
val is increased by a factor of 1.1, so that the tensor size for the first iterations would be:
torch.Size([17])
torch.Size([18])
torch.Size([20])
torch.Size([22])
torch.Size([24])
torch.Size([27])
torch.Size([30])
torch.Size([33])
torch.Size([36])
torch.Size([40])

Since the loop is never terminating you are eventually running out of memory.