# Saving tensor with torch.save uses too much memory

**URL:** <https://discuss.pytorch.org/t/saving-tensor-with-torch-save-uses-too-much-memory/46865>\
**Category:** vision\
**Created:** [June 2, 2019, 9:53am UTC](https://discuss.pytorch.org/t/saving-tensor-with-torch-save-uses-too-much-memory/46865 "2019-06-02T09:53:13Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![albanD](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/alband/32/215_2.png) [@albanD](https://discuss.pytorch.org/u/albanD)\
**Post date:** [June 2, 2019, 2:42pm UTC](https://discuss.pytorch.org/t/saving-tensor-with-torch-save-uses-too-much-memory/46865/2 "2019-06-02T14:42:23Z")

</div>

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.

---

_[View the full topic](https://discuss.pytorch.org/t/saving-tensor-with-torch-save-uses-too-much-memory/46865)._
