Why my pytorch process keep expanding usage of GPU while running?
I just run a normal train file of my model, and today I suprisingly found that my process has been expanding the usage of GPU by the rate of 2 MB per training round.
Is that because I did not free some .cuda() Variable after use? I thought I did not have to free them by myself due to the autograd mechanism.
Or say, did I cause some memory leakage in GPU while running my nn.module-class model
Are you storing the loss or some other variable, which is attached to the computation graph, somewhere?
Make sure to call detach on your model output etc., if you would like to store the predictions, loss etc. for further analysis.
Oh! Mr.@ptrblck , you remind me that In my nn.module model ---- net() , there is a class variable
self.previous_feature
it is used to store the extracted feature from the last training round.
BUT, it is like, updated every round, since it is always the current previous frame feature. Would it, say, just permanently stored in GPU? but it is in a updating mode~
OR! you remind me that : the previous feature is on the computation graph, so even it is updated, the older one is still on the graph and not detached. that is the reason the updated feature still exists as a graph node. right?