You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
Race-condition and crash with SymbolBlock on GPU #18765
Severe Bug with nn.SymbolBlock when ctx=mx.gpu(0), cpu is OK.
Error Message
malloc or free or Segmentation fault error may appears randomly
/home/xxxxxx/anaconda3/envs/solo/lib/python3.7/site-packages/mxnet/gluon/block.py:1517: UserWarning: Cannot decide type for the following arguments. Consider providing them as input:
data: None
input_sym_arg_type = in_param.infer_type()[0]
[17:15:59] src/operator/nn/./cudnn/./cudnn_algoreg-inl.h:97: Running performance tests to find the best convolution algorithm, this can take a while... (set the environment variable MXNET_CUDNN_AUTOTUNE_DEFAULT to 0 to disable)
[(1, 256, 56, 56), (1, 512, 28, 28), (1, 1024, 14, 14), (1, 2048, 7, 7)]
malloc(): unsorted double linked list corrupted
[1] 87116 abort (core dumped) python symbolblockbug.py
/home/xxxxxx/anaconda3/envs/solo/lib/python3.7/site-packages/mxnet/gluon/block.py:1517: UserWarning: Cannot decide type for the following arguments. Consider providing them as input:
data: None
input_sym_arg_type = in_param.infer_type()[0]
[17:21:29] src/operator/nn/./cudnn/./cudnn_algoreg-inl.h:97: Running performance tests to find the best convolution algorithm, this can take a while... (set the environment variable MXNET_CUDNN_AUTOTUNE_DEFAULT to 0 to disable)
[(1, 256, 56, 56), (1, 512, 28, 28), (1, 1024, 14, 14), (1, 2048, 7, 7)]
Segmentation fault: 11
/home/xxxxxx/anaconda3/envs/solo/lib/python3.7/site-packages/mxnet/gluon/block.py:1517: UserWarning: Cannot decide type for the following arguments. Consider providing them as input:
data: None
input_sym_arg_type = in_param.infer_type()[0]
[17:23:24] src/operator/nn/./cudnn/./cudnn_algoreg-inl.h:97: Running performance tests to find the best convolution algorithm, this can take a while... (set the environment variable MXNET_CUDNN_AUTOTUNE_DEFAULT to 0 to disable)
[(1, 256, 56, 56), (1, 512, 28, 28), (1, 1024, 14, 14), (1, 2048, 7, 7)]
malloc_consolidate(): invalid chunk size
[1] 87701 abort (core dumped) python symbolblockbug.py
import mxnet as mx
from mxnet import gluon
from mxnet.gluon import nn
a = mx.nd.random.uniform(shape=(1,3,224,224))
backbone = gluon.model_zoo.vision.resnet18_v1()
backbone.initialize()
backbone.hybridize()
backbone(a)
# Alternative:
# backbone.reset_ctx(mx.gpu(0))
# b = backbone(a.as_in_context(mx.gpu(0)))
# print([x.shape for x in b])
sym_file, params_file = backbone.export('/tmp/model')
f = gluon.SymbolBlock.imports(sym_file, 'data', params_file)
f.reset_ctx(mx.gpu(0))
b = f(a.as_in_context(mx.gpu(0)))
print([x.shape for x in b])
It fails with
[18:59:34] ../src/storage/storage.cc:198: Using Pooled (Naive) StorageManager for CPU
/home/ubuntu/src/mxnet-master/python/mxnet/gluon/block.py:1723: UserWarning: Cannot decide type for the following arguments. Consider providing them as input:
data: None
input_sym_arg_type = in_param.infer_type()[0]
[18:59:37] ../src/storage/storage.cc:198: Using Pooled (Naive) StorageManager for GPU
[(1000,)]
[18:59:38] ../src/operator/nn/./cudnn/./cudnn_algoreg-inl.h:97: Running performance tests to find the best convolution algorithm, this can take a while... (set the environment variable MXNET_CUDNN_AUTOTUNE_DEFAULT to 0 to disable)
Segmentation fault: 11
zsh: abort (core dumped) python3 symbolblockbug.py
However, the following will work:
import mxnet as mx
from mxnet import gluon
from mxnet.gluon import nn
a = mx.nd.random.uniform(shape=(1,3,224,224))
backbone = gluon.model_zoo.vision.resnet18_v1()
backbone.initialize()
backbone.hybridize()
# backbone(a)
# Alternative:
backbone.reset_ctx(mx.gpu(0))
b = backbone(a.as_in_context(mx.gpu(0)))
print([x.shape for x in b])
sym_file, params_file = backbone.export('/tmp/model')
f = gluon.SymbolBlock.imports(sym_file, 'data', params_file)
f.reset_ctx(mx.gpu(0))
b = f(a.as_in_context(mx.gpu(0)))
print([x.shape for x in b])
Activity
chinakook commentedon Jul 21, 2020
Solved. Change the last row to
print([x.asnumpy().shape for x in b]).leezu commentedon Jul 21, 2020
@chinakook thanks for providing a workaround. I think it's still a bug
leezu commentedon Jul 21, 2020
Simpler reproducible example for latest master:
It fails with
However, the following will work:
[-]Severe Bug with nn.SymbolBlock[/-][+]Race-condition and crash with SymbolBlock on GPU[/+]leezu commentedon Jul 21, 2020
Backtrace
@ptrendx do you think this is a bug in fused op or in the engine?
eric-haibin-lin commentedon Jul 21, 2020
does adding
mx.nd.waitall()help?chinakook commentedon Jul 22, 2020
@eric-haibin-lin Yes, it does.
chinakook commentedon Jul 22, 2020
As I've tested, #18768 can solve this problem.