Open yifeim opened 5 years ago
Hey, this is the MXNet Label Bot. Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it. Here are my recommended labels: Gluon, Bug
@eric-haibin-lin helped with identifying the actual possible cause of the otherwise obscure error code.
@mxnet-label-bot add [Bug, Gluon]
@eric-haibin-lin I ran into the same issue, what was the solution in your case?
@ifeherva could you share you failed test case? "Wrap y with F.identity(y) on the inner network." -> this seems to work for @yifeim 's case
Wrapping y with F.identity(y) on the outer network also works. I think y, the input tensor, it cannot be backward because it does not pass through any operator.
I found another problem like following:
import mxnet as mx
class Net(mx.gluon.HybridBlock):
def __init__(self):
super(Net, self).__init__()
def hybrid_forward(self, F, x):
x = F.relu(x)
return x
net = Net()
net.initialize()
net.hybridize()
a = mx.nd.ones((5,5))
with mx.autograd.record():
c = net(a)
c.backward()
mx.nd.waitall()
print('pass')
Error infomation:
line 16, in <module>
c.backward()
File "C:\ProgramData\Anaconda3\lib\site-packages\mxnet\ndarray\ndarray.py", line 2192, in backward
ctypes.c_void_p(0)))
File "C:\ProgramData\Anaconda3\lib\site-packages\mxnet\base.py", line 251, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [21:29:18] C:\Jenkins\workspace\mxnet-tag\mxnet\src\imperative\imperative.cc:285: Check failed: !AGInfo::IsNone(*i) Cannot differentiate node because it is not in a computational graph. You need to set is_recording to true or use autograd.record() to save computational graphs for backward. If you want to differentiate the same graph twice, you need to pass retain_graph=True to backward.
@chinakook for this I think you need to do a.attach_grad() before autograd?
@eric-haibin-lin Yeah.
can this issue be closed?
No, these two problems seem unrelated. In fact, I have two points of confusion now: (1) The initial post had different error messaging.
MXNetError: Error in operator node_5_backward: [01:30:17] src/imperative/./imperative_utils.h:684: Check failed: g.GetAttr<size_t>("storage_type_num_unknown_nodes") == 0U (1 vs. 0)
(2) The workaround did not trigger the second error, even though variable y
was still no in the computational graph.
@yifeim There seems to be a workaround with wrapping inner network's y in F.identity()
.
Are you still facing the error ?
If not, can this issue be closed ?
@mxnet-label-bot Update [pending requester info]
Description
On a set of network/input configurations, the hybridized model returns a weird bug:
Check failed: g.GetAttr<size_t>("storage_type_num_unknown_nodes") == 0U (1 vs. 0)
Instead, this does not seem to be the true cause in any conceivable failure cases.Environment info (Required)
Package used (Python/R/Scala/Julia): Python
Minimum reproducible example
Steps to reproduce
(Paste the commands you ran that produced the error.)
MXNetError: Error in operator node_5_backward: [01:30:17] src/imperative/./imperative_utils.h:684: Check failed: g.GetAttr<size_t>("storage_type_num_unknown_nodes") == 0U (1 vs. 0)
What have you tried to solve it?
y
withF.identity(y)
on the inner network.