From 6226b521308f935fe754922d55d97758c55c9bce Mon Sep 17 00:00:00 2001 From: James Betker Date: Fri, 4 Sep 2020 15:30:46 -0600 Subject: [PATCH] Pin memory in dataloaders by default --- codes/data/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codes/data/__init__.py b/codes/data/__init__.py index aac80e77..e7070974 100644 --- a/codes/data/__init__.py +++ b/codes/data/__init__.py @@ -19,11 +19,11 @@ def create_dataloader(dataset, dataset_opt, opt=None, sampler=None): shuffle = True return torch.utils.data.DataLoader(dataset, batch_size=batch_size, shuffle=shuffle, num_workers=num_workers, sampler=sampler, drop_last=True, - pin_memory=False) + pin_memory=True) else: batch_size = dataset_opt['batch_size'] or 1 return torch.utils.data.DataLoader(dataset, batch_size=batch_size, shuffle=False, num_workers=max(int(batch_size/2), 1), - pin_memory=False) + pin_memory=True) def create_dataset(dataset_opt):