That’s right, loader
is not instantiated. This is DataLoader1
class DataLoader1():
def __init__(self, trg_file_path, emb_indices, batch_size, max_seq_len, label_signature=None,
sample_per_word=False, one_hot_labels=False, update_emb_indices=False,
infinite_batches=False, intents_to_use=None, device=None, num_samples_key='num_samples',
get_raw_samples_while_iter=False, debug_mode=False):
"""
Iterator to feed trg data
args:;
labels = [
('intent',[None, 'greet', 'direction']),
('action',[None, 'enquire', 'navigate']),
('subject',[None, 'thank', 'hello'])
]
or
labels = [None, 'person','location','day', 'time']
batches_to_produce:
-1 - feeds indefinitely
0 - Feeds till the file exhausts
<int value> - feeds <value> batches and exits
intents_to_use - if a list is provided, excludes samples not included in this list
"""
if debug_mode:
torch.set_printoptions(threshold=10000)
else:
torch.set_printoptions(threshold=500)
self.emb_indices = emb_indices
self.batch_size = batch_size
self.max_seq_len = max_seq_len
self.sample_per_word = sample_per_word
self.one_hot_labels = one_hot_labels
self.update_emb_indices = update_emb_indices
self.get_raw_samples_while_iter = get_raw_samples_while_iter
self.sample_ptr = 0
self.infinite_batches = infinite_batches
self.num_samples_key = num_samples_key
print ('Preparing data from file = {}'.format(trg_file_path))
self.phrase_match, self.num_samples, self.intents_to_train, labels_from_trg_file = getClasses(
trg_file_path,intents_to_get=intents_to_use,
num_samples_key=num_samples_key)
self.labels = labels_from_trg_file if label_signature is None else label_signature
if device:
self.device = device
else:
self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
if get_raw_samples_while_iter:
self.samples = []
# calc feature vec size
try:
self.features_vec = torch.zeros((self.num_samples, self.max_seq_len), dtype=torch.long, device=self.device)
except RuntimeError as e:
torch.cuda.empty_cache()
raise e
As you can see self.features_vec
is the 1st tensor that is created, all others are trivial and small python variables. I tried clearing cache with a try block, but that didnt help.
Yes I’m getting OOM in DataLoader2 just after DataLoader1 fails to instantiate. If I run just DataLoader2 it works fine (That’s how I am training now)