models icon indicating copy to clipboard operation
models copied to clipboard

Resnet 中 elementwise_add 的顺序影响显存大小?

Open mzchtx opened this issue 7 years ago • 1 comments

使用 Resnet 训练分类模型,发现 elementwise_add layer 中变量x 和 y 的顺序会影响 10% 以上。

return fluid.layers.elementwise_add(x=short, y=conv2, act='relu',name=name+".add.output.5")

return fluid.layers.elementwise_add(x=short, y=conv1, act='relu')

修改为:

return fluid.layers.elementwise_add(x=conv2, y=short, act='relu',name=name+".add.output.5")

return fluid.layers.elementwise_add(x=conv2, y=short, act='relu')

显存占用从 5.3 G 降低到 4.8 G,请问是因为影响了显存复用导致的吗?

image

code

mzchtx avatar Jul 17 '19 09:07 mzchtx

使用 Resnet 训练分类模型,发现 elementwise_add layer 中变量x 和 y 的顺序会影响 10% 以上。

return fluid.layers.elementwise_add(x=short, y=conv2, act='relu',name=name+".add.output.5")

return fluid.layers.elementwise_add(x=short, y=conv1, act='relu')

修改为:

return fluid.layers.elementwise_add(x=conv2, y=short, act='relu',name=name+".add.output.5")

return fluid.layers.elementwise_add(x=conv2, y=short, act='relu')

显存占用从 5.3 G 降低到 4.8 G,请问是因为影响了显存复用导致的吗?

image

code

您好,这个的确是因为显存复用导致的。 我们正在测试我们的内存/显存garbage collection功能,后续版本启用之后,这个问题就不会再有了。

liupluswei avatar Jul 18 '19 12:07 liupluswei