apache / mxnet

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more
https://mxnet.apache.org
Apache License 2.0
20.77k stars 6.79k forks source link

DataLoader timed out #18224

Closed hsneto closed 4 years ago

hsneto commented 4 years ago

Description

Whenever I set num_workers > 0 in gluon.data.DataLoader I get timed out.

Error Message

Worker timed out after 120 seconds. This might be caused by 

            - Slow transform. Please increase timeout to allow slower data loading in each worker.
            - Insufficient shared_memory if `timeout` is large enough.
            Please consider reduce `num_workers` or increase shared_memory in system.

---------------------------------------------------------------------------
TimeoutError                              Traceback (most recent call last)
<ipython-input-5-bf565db5d0a6> in <module>
      1 lr, num_epochs = 0.01, 1
----> 2 d2l.train_ch6(net, train_iter, test_iter, num_epochs, lr)

/usr/local/lib/python3.5/dist-packages/d2l/d2l.py in train_ch6(net, train_iter, test_iter, num_epochs, lr, ctx)
    419     for epoch in range(num_epochs):
    420         metric = d2l.Accumulator(3)  # train_loss, train_acc, num_examples
--> 421         for i, (X, y) in enumerate(train_iter):
    422             timer.start()
    423             # Here is the only difference compared to train_epoch_ch3

/usr/local/lib/python3.5/dist-packages/mxnet/gluon/data/dataloader.py in __next__(self)
    503         try:
    504             if self._dataset is None:
--> 505                 batch = pickle.loads(ret.get(self._timeout))
    506             else:
    507                 batch = ret.get(self._timeout)

/usr/lib/python3.5/multiprocessing/pool.py in get(self, timeout)
    602         self.wait(timeout)
    603         if not self.ready():
--> 604             raise TimeoutError
    605         if self._success:
    606             return self._value

TimeoutError: 

To Reproduce

I'm using the mxnet docker image: mxnet/python:nightly_gpu_cu102_mkl_py3.

The notebook to reproduce can be find in d2l.ai - Ch. 7.1.

Environment

We recommend using our script for collecting the diagnositc information. Run the following command and paste the outputs below:

curl --retry 10 -s https://raw.githubusercontent.com/dmlc/gluon-nlp/master/tools/diagnose.py | python

----------Python Info----------
Version      : 3.5.2
Compiler     : GCC 5.4.0 20160609
Build        : ('default', 'Oct  8 2019 13:06:37')
Arch         : ('64bit', 'ELF')
------------Pip Info-----------
Version      : 20.0.2
Directory    : /usr/local/lib/python3.5/dist-packages/pip
----------MXNet Info-----------
Version      : 1.6.0
Directory    : /usr/local/lib/python3.5/dist-packages/mxnet
Num GPUs     : 1
Hashtag not found. Not installed from pre-built package.
----------System Info----------
Platform     : Linux-5.3.0-51-generic-x86_64-with-Ubuntu-16.04-xenial
system       : Linux
node         : archmage
release      : 5.3.0-51-generic
version      : #44~18.04.2-Ubuntu SMP Thu Apr 23 14:27:18 UTC 2020
----------Hardware Info----------
machine      : x86_64
processor    : x86_64
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                6
On-line CPU(s) list:   0-5
Thread(s) per core:    1
Core(s) per socket:    6
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 158
Model name:            Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
Stepping:              10
CPU MHz:               3800.000
CPU max MHz:           4000.0000
CPU min MHz:           800.0000
BogoMIPS:              5599.85
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              9216K
NUMA node0 CPU(s):     0-5
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d
----------Network Test----------
Setting timeout: 10
Timing for GluonNLP: http://gluon-nlp.mxnet.io, DNS: 0.0358 sec, LOAD: 0.8158 sec.
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0233 sec, LOAD: 0.9208 sec.
Error open Conda: https://repo.continuum.io/pkgs/free/, HTTP Error 403: Forbidden, DNS finished in 0.003752470016479492 sec.
Timing for GluonNLP GitHub: https://github.com/dmlc/gluon-nlp, DNS: 0.1257 sec, LOAD: 0.6051 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0428 sec, LOAD: 1.0215 sec.
Timing for D2L: http://d2l.ai, DNS: 0.0392 sec, LOAD: 0.5139 sec.
Timing for D2L (zh-cn): http://zh.d2l.ai, DNS: 0.0375 sec, LOAD: 0.3158 sec.
Timing for FashionMNIST: https://repo.mxnet.io/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0358 sec, LOAD: 0.9466 sec.
leezu commented 4 years ago

Have you tried " - Slow transform. Please increase timeout to allow slower data loading in each worker."?

leezu commented 4 years ago

Close due to lack of response

hsneto commented 4 years ago

Sorry for the late answer. Yes, I tried to increase the timeout to 300, but it didn't work.

huzhouxiang commented 4 years ago

have you resolved this issue yet ? I also got this issue after I wrote a gluon.Dataset by myself, but I can' t figure it out

leezu commented 4 years ago

@huzhouxiang I suggest you open a new issue containing a minimal reproducible example

Mauhing commented 4 years ago

I solved it. I have the same problem in d2l.ai - Ch. 7.7. Use --shm 1024m to lauch docker, so docker run --shm 1024m <bla bla bla>

why? gluon.data.DataLoader use python multiprocess, multiprocess need shared memory. The default shared memory is 64m in docker container. You can check the shm usage by using df -h and find shm.