I use item() and del out1 to avoid CUDA out of memory .
But still occurs.
Is there any tips for avoid out of memory?
Here is my training flow.
optimizer.zero_grad()
out1 = network(input)
loss1 = criterion(out1, target1
loss += loss1.item()
del out1

out2 = network(input)
loss2 = criterion(out2, target)
loss += loss2.item()
del out2

loss.backward()