You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by gi...@git.apache.org on 2017/08/24 06:24:12 UTC
[GitHub] SherlockLiao opened a new issue #7589: gluon rnn bug
SherlockLiao opened a new issue #7589: gluon rnn bug
URL: https://github.com/apache/incubator-mxnet/issues/7589
For bugs or installation issues, please provide the following information.
The more information you provide, the more likely people will be able to help you.
## Environment info
Operating System: Ubuntu 16.04.2 LTS
Compiler:
Package used (Python/R/Scala/Julia): python
MXNet version: mxnet-cu80 0.11
Or if installed from source:
MXNet commit hash (`git rev-parse HEAD`):
If you are using python package, please provide
Python version and distribution:
If you are using R package, please provide
R `sessionInfo()`:
## Error Message:
From the document, I know I can run the rnn or lstm layer only feeding in input, don't need to feed in hidden state, I can run it in CPU but I can't run it in GPU, maybe there is a bug. This is my example code.
```python
layer = gluon.rnn.LSTM(100, 3)
layer.initialize()
input = mx.nd.random_uniform(shape=(5, 3, 10))
output = layer(input)
print(output.shape)
```
If I run this, I can get the result. But if I put it on GPU, there is an error.
```python
layer = gluon.rnn.LSTM(100, 3)
layer.initialize(ctx=mx.gpu())
input = mx.nd.random_uniform(shape=(5, 3, 10), ctx=mx.gpu())
output = layer(input)
print(output.shape)
```
MXNetError Traceback (most recent call last)
<ipython-input-7-da2f5a81429d> in <module>()
2 layer.initialize(ctx=mx.gpu())
3 input = mx.nd.random_uniform(shape=(5, 3, 10), ctx=mx.gpu())
----> 4 output = layer(input)
5 print(output.shape)
/home/sherlock/anaconda3/envs/mx/lib/python3.6/site-packages/mxnet/gluon/block.py in __call__(self, *args)
266 def __call__(self, *args):
267 """Calls forward. Only accepts positional arguments."""
--> 268 return self.forward(*args)
269
270 def forward(self, *args):
/home/sherlock/anaconda3/envs/mx/lib/python3.6/site-packages/mxnet/gluon/rnn/rnn_layer.py in forward(self, inputs, states)
186 self.i2h_weight[i]._finish_deferred_init()
187 if inputs.context.device_type == 'gpu':
--> 188 out = self._forward_gpu(inputs, states)
189 else:
190 out = self._forward_cpu(inputs, states)
/home/sherlock/anaconda3/envs/mx/lib/python3.6/site-packages/mxnet/gluon/rnn/rnn_layer.py in _forward_gpu(self, inputs, states)
218 rnn = ndarray.RNN(inputs, params, *states, state_size=self._hidden_size,
219 num_layers=self._num_layers, bidirectional=self._dir == 2,
--> 220 p=self._dropout, state_outputs=True, mode=self._mode)
221
222 if self._mode == 'lstm':
/home/sherlock/anaconda3/envs/mx/lib/python3.6/site-packages/mxnet/ndarray.py in RNN(data, parameters, state, state_cell, state_size, num_layers, bidirectional, mode, p, state_outputs, out, name, **kwargs)
/home/sherlock/anaconda3/envs/mx/lib/python3.6/site-packages/mxnet/_ctypes/ndarray.py in _imperative_invoke(handle, ndargs, keys, vals, out)
87 ctypes.c_int(len(keys)),
88 c_array(ctypes.c_char_p, [c_str(key) for key in keys]),
---> 89 c_array(ctypes.c_char_p, [c_str(str(val)) for val in vals])))
90
91 if original_output is not None:
/home/sherlock/anaconda3/envs/mx/lib/python3.6/site-packages/mxnet/base.py in check_call(ret)
127 """
128 if ret != 0:
--> 129 raise MXNetError(py_str(_LIB.MXGetLastError()))
130
131 if sys.version_info[0] < 3:
MXNetError: [14:22:00] src/c_api/c_api_ndarray.cc:128: Check failed: ndinputs[i].ctx().dev_mask() == ctx.dev_mask() (1 vs. 2) All inputs must live on the same context. But the first argument is on gpu(0) while the 3-th argument is on cpu(0)
Stack trace returned 10 entries:
[bt] (0) /home/sherlock/anaconda3/envs/mx/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x1d57cc) [0x7f819f9eb7cc]
[bt] (1) /home/sherlock/anaconda3/envs/mx/lib/python3.6/site-packages/mxnet/libmxnet.so(+0xdec2e1) [0x7f81a06022e1]
[bt] (2) /home/sherlock/anaconda3/envs/mx/lib/python3.6/site-packages/mxnet/libmxnet.so(+0xdf2af1) [0x7f81a0608af1]
[bt] (3) /home/sherlock/anaconda3/envs/mx/lib/python3.6/site-packages/mxnet/libmxnet.so(MXImperativeInvoke+0x254) [0x7f81a06097a4]
[bt] (4) /home/sherlock/anaconda3/envs/mx/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(ffi_call_unix64+0x4c) [0x7f81d7cda5a0]
[bt] (5) /home/sherlock/anaconda3/envs/mx/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(ffi_call+0x1f5) [0x7f81d7cd9d45]
[bt] (6) /home/sherlock/anaconda3/envs/mx/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(_ctypes_callproc+0x3dc) [0x7f81d7cd188c]
[bt] (7) /home/sherlock/anaconda3/envs/mx/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so(+0x9df3) [0x7f81d7cc9df3]
[bt] (8) /home/sherlock/anaconda3/envs/mx/bin/../lib/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x9e) [0x7f81de8efaae]
[bt] (9) /home/sherlock/anaconda3/envs/mx/bin/../lib/libpython3.6m.so.1.0(+0x1482bb) [0x7f81de9cc2bb]
I think the reason is the default hidden state in on cpu and if I put the layer and input on GPU, the hidden state is not on GPU.
## Minimum reproducible example
if you are using your own code, please provide a short script that reproduces the error.
## Steps to reproduce
or if you are running standard examples, please provide the commands you have run that lead to the error.
1.
2.
3.
## What have you tried to solve it?
1.
2.
3.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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