Hi,
Deleting all the Tensors that reference the graph is enough to free it.
In your case, the del outputs should do the trick. How do you know the computational graph is kept around?
Note that zeroing the gradients does not remove the .grad field, it just zeros them. So the .grad attributes will still consume some memory. You can give set_to_none=True to the zero grad function to actually free these TEnsors.