@ptrblck you are right, removed this line and no more memory leak
#torch.autograd.set_detect_anomaly(True)
copy your suggestions here: “…you are using anomaly detection via torch.autograd.set_detect_anomaly(True) , which is a debug tool and was causing an increasing memory usage in the past. Could you disable it, once you’ve debugged your code (this mode would also slow down your code so should only be used while debugging)?..”
thank you.