As mentioned, if you want to backward through the graph multiple times, you have to specify retain_graph=True for all but the last call.
Note that this can happen as well if you do some computations before your training loop and you re-use part of the graph for all the iterations. you should recompute all the graph at every iteration!