Skip to content

Commit

Permalink
enable option to disable pin_memory in pytorch (#239)
Browse files Browse the repository at this point in the history
* enable option to disable pin_memory in pytorch

* add the docs for pytorch pin memory
rayandrew authored Oct 30, 2024

Verified

This commit was signed with the committer’s verified signature.
fengmk2 fengmk2
1 parent cc5abbc commit c9225fb
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dlio_benchmark/data_loader/torch_data_loader.py
Original file line number Diff line number Diff line change
@@ -143,7 +143,7 @@ def read(self):
batch_size=self.batch_size,
sampler=sampler,
num_workers=self._args.read_threads,
pin_memory=True,
pin_memory=self._args.pin_memory,
drop_last=True,
worker_init_fn=dataset.worker_init,
**kwargs)
@@ -152,7 +152,7 @@ def read(self):
batch_size=self.batch_size,
sampler=sampler,
num_workers=self._args.read_threads,
pin_memory=True,
pin_memory=self._args.pin_memory,
drop_last=True,
worker_init_fn=dataset.worker_init,
**kwargs) # 2 is the default value
3 changes: 3 additions & 0 deletions dlio_benchmark/utils/config.py
Original file line number Diff line number Diff line change
@@ -118,6 +118,7 @@ class ConfigArguments:
data_loader_sampler: DataLoaderSampler = None
reader_classname: str = None
multiprocessing_context: str = "fork"
pin_memory: bool = True

# derived fields
required_samples: int = 1
@@ -521,6 +522,8 @@ def LoadConfig(args, config):
args.preprocess_time = reader['preprocess_time']
if 'preprocess_time_stdev' in reader:
args.preprocess_time_stdev = reader['preprocess_time_stdev']
if 'pin_memory' in reader:
args.pin_memory = reader['pin_memory']

# training relevant setting
if 'train' in config:
3 changes: 3 additions & 0 deletions docs/source/config.rst
Original file line number Diff line number Diff line change
@@ -201,6 +201,9 @@ reader
* - read_threads*
- 1
- number of threads to load the data (for tensorflow and pytorch data loader)
* - pin_memory
- True
- whether to pin the memory for pytorch data loader
* - computation_threads
- 1
- number of threads to preprocess the data

0 comments on commit c9225fb

Please sign in to comment.