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 2019/03/04 22:30:09 UTC
[GitHub] [incubator-mxnet] anirudhacharya commented on issue #13199:
Namescope is None when hybridize in multi-threading environment.
AttributeError: 'NoneType' object has no attribute '__exit__'
anirudhacharya commented on 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#issuecomment-469448283
mxnet in general is not thread safe. You can accomplish the above using multiprocessing.
```python
import multiprocessing as mp
import gluoncv
import mxnet as mx
net = gluoncv.model_zoo.resnet18_v1b(pretrained=True)
net.hybridize()
def worker(module, input, outputs):
outnd = module(input) # type: mx.nd.NDArray
outnd.wait_to_read()
outputs.put(outnd)
ps = []
outputs = mp.Queue(5)
for i in range(3):
input1 = mx.random.randn(1, 3, 368, 368)
p = mp.Process(target=worker, args=(net, input1, outputs))
ps.append(p)
for p in ps:
p.start()
for p in ps:
p.join()
while not outputs.empty():
print(outputs.get().shape)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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