Skip to content

Commit 7763c6f

Browse files
Erotemicsoumith
authored andcommitted
Raise errors when num_workers == 0 in DataLoader (#4019)
1 parent 98879d5 commit 7763c6f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

torch/utils/data/dataloader.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ def __init__(self, dataset, batch_size=1, shuffle=False, sampler=None, batch_sam
295295
if sampler is not None and shuffle:
296296
raise ValueError('sampler is mutually exclusive with shuffle')
297297

298+
if self.num_workers < 0:
299+
raise ValueError('num_workers cannot be negative; '
300+
'use num_workers=0 to disable multiprocessing.')
301+
298302
if batch_sampler is None:
299303
if sampler is None:
300304
if shuffle:

0 commit comments

Comments
 (0)