Skip to content

Commit d0b7e37

Browse files
maxwbuckleysoumith
authored andcommitted
Update main.py tutorial, set persistent_workers, make GPU execution much faster
Since we are setting num_workers to 1, we should either make this worker persistent or not set the num_workers. On my machine, running this script as is takes 2.21 mins, setting the workers to persistent or removing num_workers (setting to its default of 0) makes it a good deal faster at 1.44 and 1.66 mins respectively. I would opt for adding the persistent_workers setting as it is a little faster and makes it trivial for even a beginner to speed it up further by increasing the num_workers (setting to 10 reduced my run time to 0.53 mins
1 parent 4206858 commit d0b7e37

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mnist/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def main():
107107
test_kwargs = {'batch_size': args.test_batch_size}
108108
if use_accel:
109109
accel_kwargs = {'num_workers': 1,
110+
'persistent_workers': True,
110111
'pin_memory': True,
111112
'shuffle': True}
112113
train_kwargs.update(accel_kwargs)

0 commit comments

Comments
 (0)