Saving tensor with torch.save uses too much memory

Hi,

selecting a subset of a tensor does not actually create a new tensor in most cases but just looks at a subset of the original one.
When saving, the original tensor is saved.
You can save training_set.data[:25].clone() to save only the part you want as the clone operation will force the creation of a new smaller tensor containing your data.

6 Likes