Skip to content

Commit 5c13c69

Browse files
Erotemicapaszke
authored andcommitted
Raise errors when num_workers == 0 in DataLoader (#4019)
1 parent 7842b4b commit 5c13c69

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
@@ -361,6 +361,10 @@ def __init__(self, dataset, batch_size=1, shuffle=False, sampler=None, batch_sam
361361
if sampler is not None and shuffle:
362362
raise ValueError('sampler is mutually exclusive with shuffle')
363363

364+
if self.num_workers < 0:
365+
raise ValueError('num_workers cannot be negative; '
366+
'use num_workers=0 to disable multiprocessing.')
367+
364368
if batch_sampler is None:
365369
if sampler is None:
366370
if shuffle:

0 commit comments

Comments
 (0)