Thank you
Sorry for the late reply. I think it’s a good idea and worth trying. I have tested that after I reduce my network to a simpler one and only output the loss.item() in my training loop for simplicity then the memory error had gone away. However, it seems that my code would consume as much memory as I allocated, which is still strange. Anyway, thanks for your reply and time again.