File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 13
13
import os
14
14
import pickle
15
15
import time
16
+ import warnings
16
17
from collections .abc import Callable , Iterable , Iterator
17
18
from concurrent .futures import ProcessPoolExecutor
18
19
from multiprocessing .shared_memory import SharedMemory
@@ -298,8 +299,14 @@ def get_pytorch_dataloader(
298
299
if timeout is not None and timeout < 0 :
299
300
raise ValueError (f"`timeout` must be positive. Found: { timeout } ." )
300
301
301
- if num_workers < 1 :
302
+ if num_workers < 0 :
302
303
raise ValueError (f"`num_workers` must be greater than 0. Found: { num_workers } " )
304
+ elif num_workers == 0 :
305
+ warnings .warn (
306
+ "`num_workers` is 0. Setting `num_workers` to 1 for single process dataloading." ,
307
+ stacklevel = 2 ,
308
+ )
309
+ num_workers = 1
303
310
304
311
buffer_size = prefetch_factor * num_workers
305
312
You can’t perform that action at this time.
0 commit comments