You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/11/09 11:51:56 UTC

[GitHub] kohillyang opened a new issue #13199: Namescope is None when hybridize in multi-threading environment. AttributeError: 'NoneType' object has no attribute '__exit__'

kohillyang opened a new issue #13199: Namescope is None when hybridize in multi-threading environment. AttributeError: 'NoneType' object has no attribute '__exit__'
URL: https://github.com/apache/incubator-mxnet/issues/13199
 
 
   ## Description
   (Brief description of the problem in no more than 2 sentences.)
   
   ## Environment info (Required)
   
   ```
   ----------Python Info----------
   ('Version      :', '2.7.15')
   ('Compiler     :', 'GCC 7.2.0')
   ('Build        :', ('default', 'May  1 2018 23:32:55'))
   ('Arch         :', ('64bit', ''))
   ------------Pip Info-----------
   ('Version      :', '18.1')
   ('Directory    :', '/home/kohill/anaconda2/lib/python2.7/site-packages/pip')
   ----------MXNet Info-----------
   ('Version      :', '1.3.0')
   ('Directory    :', '/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet')
   ('Commit Hash   :', 'b3be92f4a48bce62a5a8424271871c2f81c8f7f1')
   ----------System Info----------
   ('Platform     :', 'Linux-4.15.0-36-generic-x86_64-with-debian-stretch-sid')
   ('system       :', 'Linux')
   ('node         :', 'heils-server')
   ('release      :', '4.15.0-36-generic')
   ('version      :', '#39~16.04.1-Ubuntu SMP Tue Sep 25 08:59:23 UTC 2018')
   ----------Hardware Info----------
   ('machine      :', 'x86_64')
   ('processor    :', 'x86_64')
   Architecture:          x86_64
   CPU \u8fd0\u884c\u6a21\u5f0f\uff1a    32-bit, 64-bit
   Byte Order:            Little Endian
   CPU(s):                40
   On-line CPU(s) list:   0-39
   \u6bcf\u4e2a\u6838\u7684\u7ebf\u7a0b\u6570\uff1a2
   \u6bcf\u4e2a\u5ea7\u7684\u6838\u6570\uff1a  10
   Socket(s):             2
   NUMA \u8282\u70b9\uff1a         2
   \u5382\u5546 ID\uff1a           GenuineIntel
   CPU \u7cfb\u5217\uff1a          6
   \u578b\u53f7\uff1a              63
   Model name:            Intel(R) Xeon(R) CPU E5-2650 v3 @ 2.30GHz
   \u6b65\u8fdb\uff1a              2
   CPU MHz\uff1a             1197.546
   CPU max MHz:           3000.0000
   CPU min MHz:           1200.0000
   BogoMIPS:              4591.39
   \u865a\u62df\u5316\uff1a           VT-x
   L1d \u7f13\u5b58\uff1a          32K
   L1i \u7f13\u5b58\uff1a          32K
   L2 \u7f13\u5b58\uff1a           256K
   L3 \u7f13\u5b58\uff1a           25600K
   NUMA node0 CPU(s):     0-9,20-29
   NUMA node1 CPU(s):     10-19,30-39
   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 arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb invpcid_single pti intel_ppin ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm xsaveopt cqm_llc cqm_occup_llc dtherm ida arat pln pts flush_l1d
   ----------Network Test----------
   Setting timeout: 10
   Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0046 sec, LOAD: 0.8261 sec.
   Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0039 sec, LOAD: 3.3043 sec.
   Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.3213 sec, LOAD: 1.9182 sec.
   Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0029 sec, LOAD: 0.6460 sec.
   Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0032 sec, LOAD: 1.9723 sec.
   Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.5289 sec, LOAD: 1.0473 sec.
   
   
   ```
   
   Package used (Python/R/Scala/Julia):
   (I'm using Python)
   
   ## Error Message:
   ```
   /home/kohill/anaconda2/bin/python /home/kohill/Desktop/mx-detection/bug_example.py
   Model file is not found. Downloading.
   Downloading /home/kohill/.mxnet/models/resnet18_v1b-2d9d980c.zip from https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/models/resnet18_v1b-2d9d980c.zip...
   42433KB [00:46, 909.00KB/s]                            
   /home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py:421: UserWarning: load_params is deprecated. Please use load_parameters.
     warnings.warn("load_params is deprecated. Please use load_parameters.")
   Exception in thread Thread-5:
   Traceback (most recent call last):
     File "/home/kohill/anaconda2/lib/python2.7/threading.py", line 801, in __bootstrap_inner
       self.run()
     File "/home/kohill/anaconda2/lib/python2.7/threading.py", line 754, in run
       self.__target(*self.__args, **self.__kwargs)
     File "/home/kohill/Desktop/mx-detection/bug_example.py", line 10, in worker
       outnd = module(inputs)  # type: mx.nd.NDArray
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 541, in __call__
       out = self.forward(*args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 908, in forward
       return self._call_cached_op(x, *args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 798, in _call_cached_op
       self._build_cache(*args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 750, in _build_cache
       data, out = self._get_graph(*args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 742, in _get_graph
       out = self.hybrid_forward(symbol, *grouped_inputs, **params)  # pylint: disable=no-value-for-parameter
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 85, in __exit__
       self._name_scope.__exit__(ptype, value, trace)
   AttributeError: 'NoneType' object has no attribute '__exit__'
   
   Exception in thread Thread-3:
   Traceback (most recent call last):
     File "/home/kohill/anaconda2/lib/python2.7/threading.py", line 801, in __bootstrap_inner
       self.run()
     File "/home/kohill/anaconda2/lib/python2.7/threading.py", line 754, in run
       self.__target(*self.__args, **self.__kwargs)
     File "/home/kohill/Desktop/mx-detection/bug_example.py", line 10, in worker
       outnd = module(inputs)  # type: mx.nd.NDArray
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 541, in __call__
       out = self.forward(*args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 908, in forward
       return self._call_cached_op(x, *args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 798, in _call_cached_op
       self._build_cache(*args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 750, in _build_cache
       data, out = self._get_graph(*args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 742, in _get_graph
       out = self.hybrid_forward(symbol, *grouped_inputs, **params)  # pylint: disable=no-value-for-parameter
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 85, in __exit__
       self._name_scope.__exit__(ptype, value, trace)
   AttributeError: 'NoneType' object has no attribute '__exit__'
   
   Exception in thread Thread-4:
   Traceback (most recent call last):
     File "/home/kohill/anaconda2/lib/python2.7/threading.py", line 801, in __bootstrap_inner
       self.run()
     File "/home/kohill/anaconda2/lib/python2.7/threading.py", line 754, in run
       self.__target(*self.__args, **self.__kwargs)
     File "/home/kohill/Desktop/mx-detection/bug_example.py", line 10, in worker
       outnd = module(inputs)  # type: mx.nd.NDArray
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 541, in __call__
       out = self.forward(*args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 908, in forward
       return self._call_cached_op(x, *args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 798, in _call_cached_op
       self._build_cache(*args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 750, in _build_cache
       data, out = self._get_graph(*args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 742, in _get_graph
       out = self.hybrid_forward(symbol, *grouped_inputs, **params)  # pylint: disable=no-value-for-parameter
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/gluoncv/model_zoo/resnetv1b.py", line 235, in hybrid_forward
       x = self.conv1(x)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 541, in __call__
       out = self.forward(*args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 925, in forward
       return self.hybrid_forward(symbol, x, *args, **params)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 85, in __exit__
       self._name_scope.__exit__(ptype, value, trace)
   AttributeError: 'NoneType' object has no attribute '__exit__'
   
   Exception in thread Thread-2:
   Traceback (most recent call last):
     File "/home/kohill/anaconda2/lib/python2.7/threading.py", line 801, in __bootstrap_inner
       self.run()
     File "/home/kohill/anaconda2/lib/python2.7/threading.py", line 754, in run
       self.__target(*self.__args, **self.__kwargs)
     File "/home/kohill/Desktop/mx-detection/bug_example.py", line 10, in worker
       outnd = module(inputs)  # type: mx.nd.NDArray
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 541, in __call__
       out = self.forward(*args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 908, in forward
       return self._call_cached_op(x, *args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 798, in _call_cached_op
       self._build_cache(*args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 750, in _build_cache
       data, out = self._get_graph(*args)
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 742, in _get_graph
       out = self.hybrid_forward(symbol, *grouped_inputs, **params)  # pylint: disable=no-value-for-parameter
     File "/home/kohill/anaconda2/lib/python2.7/site-packages/mxnet/gluon/block.py", line 85, in __exit__
       self._name_scope.__exit__(ptype, value, trace)
   AttributeError: 'NoneType' object has no attribute '__exit__'
   
   
   Process finished with exit code 0
   
   ```
   
   ## Minimum reproducible example
   ```python
   import gluoncv
   import threading
   import mxnet as mx
   net = gluoncv.model_zoo.resnet18_v1b(pretrained=True)
   net.hybridize()
   ctx_list = [mx.gpu(x) for x in [0,1,2,3]]
   
   
   def worker(module, inputs, i, lock,  outputs):
       outnd = module(inputs)  # type: mx.nd.NDArray
       outnd.wait_to_read()
       with lock:
           outputs[i] = outnd
   
   
   threads = []
   outputs = []
   lock = threading.Lock()
   for i in range(len(ctx_list)):
       thread = threading.Thread(target=worker, args=(net, mx.random.randn(1, 3, 368, 368), i, lock, outputs))
       threads.append(thread)
   
   for thread in threads:
       thread.start()
   for thread in threads:
       thread.join()
   
   ```
   
   ## Steps to reproduce
   (Paste the commands you ran that produced the error.)
   
   1.
   2.
   
   ## What have you tried to solve it?
   
   Forward once before starting the thread.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services