I am attempting to backward the loss on each different model. However, there is bug that stated
RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time.
From my understanding, I have placed the 2 models on separate GPU and the losses are defined separately, why is there still a bug like this…
The following is my code snippet

1.jpg2350×1308 316 KB