Tutorial Example

Fix torch.save() Take Much Disk Space – PyTorch Tutorial

When we use torch.save() to save some tensors, we find the saved files take too much disk space.

For example, we have splited a big wave file to some small ones by torch ( each small file is 5 senconds). We saved these small files with torch.save(). However, each saved file is 35MB.

How to fix this error?

It is simple, we can use code below to fix it.

torch.save(wave_data.clone(), wave_file, _use_new_zipfile_serialization=True)

The most important is get wave_data.clone(), which means we will only save wave_data itself.