You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/10/03 13:37:09 UTC
[GitHub] [incubator-mxnet] kohillyang edited a comment on issue #19264: Same Network can hybridize on CPU but can not hybridize on GPU.
kohillyang edited a comment on issue #19264:
URL: https://github.com/apache/incubator-mxnet/issues/19264#issuecomment-703104893
There is a simpler reproduce case:
```python
import os
os.environ["DMLC_LOG_STACK_TRACE_DEPTH"]="10"
# os.environ["MXNET_USE_FUSION"]="0"
import mxnet as mx
import mxnet.gluon as gluon
class HighResolutionModule(gluon.nn.HybridBlock):
def __init__(self):
super(HighResolutionModule, self).__init__()
self.relu = mx.gluon.nn.Activation("relu")
self.fff = mx.gluon.nn.Conv2D(in_channels=64, channels=64, kernel_size=3, padding=1)
self.fff1 = mx.gluon.nn.Conv2D(in_channels=64, channels=64, kernel_size=3, padding=1, strides=1)
def hybrid_forward(self, F, x0, x1):
x = [x0, x1]
print(x)
y0 = (x[0] + self.fff(x[1])).relu()
y1 = (self.fff1(x[0]) + x[1]).relu()
return y0 + y1
if __name__ == '__main__':
ctx = mx.gpu()
model = HighResolutionModule()
model.initialize()
model.collect_params().reset_ctx(ctx)
model.hybridize()
y_hat = model(mx.nd.random.randn(1, 64, 56, 56, ctx=ctx), mx.nd.random.randn(1, 64, 56, 56, ctx=ctx))
print(y_hat.shape)
```
The input is a tuple instead of a list, so this bug is not caused by using a list as inputs. And if removing relu in the above codes, the program can exit with a segmentation fault. Furthermore, If set env "MXNET_USE_FUSION" to 0, the program can exit normally. Since as far as I know, MXNET_USE_FUSION would fuse relu into the last layer through an in-place operation.
I think this bug is caused by the fusion process.
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org