I also found the problem that memory leaks when using python list or python dict in torch.utils.data.Dataset, whenever num_workers > 0 or num_workers == 0 (I think num_workers == 0 just memory leaks slowly). I solved it when using numpy.array().
memory leak:
class traindataset(Dataset):
def __init__(self):
self.utt2fpath = {'utt1': './t1.wav', 'utt2': './t2.wav' ...}
self.utts = list(self.utt2fpath.keys())
def __getitem__(self, item):
utt = self.utts[item]
fpath = self.utt2fpath[utt]
...
without memory leak:
import numpy as np
class traindataset(Dataset):
def __init__(self):
self.utt2fpath = np.array([['utt1', './t1.wav'], ['utt2', './t2.wav'], ...])
def __getitem__(self, item):
utt = self.utt2fpath[item][0]
fpath = self.utt2fpath[item][1]
...
I also found the problem that memory leaks when using python list or python dict in torch.utils.data.Dataset, whenever num_workers > 0 or num_workers == 0 (I think num_workers == 0 just memory leaks slowly). I solved it when using numpy.array().
memory leak:
without memory leak: