NDArrayIter seems to crash when taking large numpy arrays as features/labels.
I had trouble loading my data sets as numpy arrays (they were approx. 39,000,00 by 340) to pass into my NDArrayIter function, and initially thought it may have been some issues in my network (network was not sized correctly), but then realized the issue was with NDArrayIter. First ticket filed for it was: https://github.com/dmlc/mxnet/issues/5037.
Debugged and failed method is at:
int MXNDArraySyncCopyFromCPU(NDArrayHandle handle,
const void *data,
size_t size)
method MXNDArraySyncCopyFromCPU() in file c_api.cc seems to crash. Can recreate this bug via:
import mxnet as mx
import numpy as np
final_feature= np.zeros((14401306,340))
final_target = np.zeros((14401306))
train = mx.io.NDArrayIter(final_feature, label=final_target, batch_size=100)
Error message:
mxnet/dmlc-core/include/dmlc/logging.h:235: [00:49:14] include/mxnet/./tensor_blob.h:742: Check failed: (this->shape_.Size()) == (shape.Size()) TBlob.get_with_shape: new and old shape do not match total elements
Traceback (most recent call last):
File "trial.py", line 6, in <module>
train = mx.io.NDArrayIter(final_feature, label=final_target, batch_size=100)
File "/usr/local/lib/python2.7/site-packages/mxnet-0.7.0-py2.7.egg/mxnet/io.py", line 420, in __init__
self.data = _init_data(data, allow_empty=False, default_name='data')
File "/usr/local/lib/python2.7/site-packages/mxnet-0.7.0-py2.7.egg/mxnet/io.py", line 391, in _init_data
"should be NDArray or numpy.ndarray")
TypeError: Invalid type '<type 'numpy.ndarray'>' for data, should be NDArray or numpy.ndarray
I have a feeling there must be some type of data overflow, and the copy doesn't seem to work on c++ side.
I met the same issue. When I removed the try-catch statement at io.py:324 and make the original exception to be exposed to terminal, it complains:
`File "/usr/local/lib/python2.7/dist-packages/mxnet-0.7.0-py2.7.egg/mxnet/io.py", line 355, in init self.data = _init_data(data, allow_empty=False, default_name='data')
File "/usr/local/lib/python2.7/dist-packages/mxnet-0.7.0-py2.7.egg/mxnet/io.py", line 326, in _init_data data[k] = array(v, cpu())
File "/usr/local/lib/python2.7/dist-packages/mxnet-0.7.0-py2.7.egg/mxnet/ndarray.py", line 909, in array arr[:] = source_array
File "/usr/local/lib/python2.7/dist-packages/mxnet-0.7.0-py2.7.egg/mxnet/ndarray.py", line 225, in setitem self._sync_copyfrom(value)
File "/usr/local/lib/python2.7/dist-packages/mxnet-0.7.0-py2.7.egg/mxnet/ndarray.py", line 260, in _sync_copyfrom ctypes.c_size_t(source_array.size)))
File "/usr/local/lib/python2.7/dist-packages/mxnet-0.7.0-py2.7.egg/mxnet/base.py", line 77, in check_call raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [23:21:37] include/mxnet/./tensor_blob.h:709: Check failed: (this->shape_.Size()) == (shape.Size()) TBlob.get_with_shape: new and old shape do not match total elements`
I have the same issue.
This issue is closed due to lack of activity in the last 90 days. Feel free to reopen if this is still an active issue. Thanks!