Reputation: 17
When I am using pytorch1.8.1 to train the model, the memory size of the model becomes large and small, resulting in frequent reports of out of memory. What is the general reason for this large and small memory?
I tried using torch.cuda.empty_cache(), but still have this problem.
Upvotes: -2
Views: 49
Reputation: 571
the cuda is malloc the ram and free it during training.
using the smaller batch_size will solve the problem, and you should check the use of torch.tensor in cuda, avoiding big tensor, or you can del big torch.tensor.cuda after using it.
Upvotes: 1