Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSError: 269892000 requested and 269188084 written

Tags:

python-3.x

Here while executing the line "array.tofile(fp)" OSError is arising which says "OSError: 269892000 requested and 269188084 written". Can I know what exactly this means and what is the possible solution for this?

def write_array(fp, array, version=None, allow_pickle=True, pickle_kwargs=None):
    ...
    ...**strong text**
    _check_version(version)
    used_ver = _write_array_header(fp, header_data_from_array_1_0(array),
                                   version)
    # this warning can be removed when 1.9 has aged enough
    if version != (2, 0) and used_ver == (2, 0):
        warnings.warn("Stored array in format 2.0. It can only be"
                      "read by NumPy >= 1.9", UserWarning)

# Set buffer size to 16 MiB to hide the Python loop overhead.
buffersize = max(16 * 1024 ** 2 // array.itemsize, 1)

if array.dtype.hasobject:
    # We contain Python objects so we cannot write out the data
    # directly.  Instead, we will pickle it out with version 2 of the
    # pickle protocol.
    if not allow_pickle:
        raise ValueError("Object arrays cannot be saved when "
                         "allow_pickle=False")
    if pickle_kwargs is None:
        pickle_kwargs = {}
    pickle.dump(array, fp, protocol=2, **pickle_kwargs)
elif array.flags.f_contiguous and not array.flags.c_contiguous:
    if isfileobj(fp):
        array.T.tofile(fp)
    else:
        for chunk in numpy.nditer(
                array, flags=['external_loop', 'buffered', 'zerosize_ok'],
                buffersize=buffersize, order='F'):
            fp.write(chunk.tobytes('C'))
else:
    if isfileobj(fp):
        print("Entered1")
        array.tofile(fp)
    else:
        for chunk in numpy.nditer(
                array, flags=['external_loop', 'buffered', 'zerosize_ok'],
                buffersize=buffersize, order='C'):
            fp.write(chunk.tobytes('C'))
like image 306
Padmaja Bhagwat Avatar asked Jun 06 '16 12:06

Padmaja Bhagwat


2 Answers

This issue arises when you are reading in data using variations of numpy.load but you don't have enough space in your drive.

The error basically means that numpy is requesting 269892000 but due to space limitations, it was only able to read/save in 269188084.

Free up some space!

like image 80
The_Aron Avatar answered Nov 14 '22 04:11

The_Aron


I got a similar error that apparently results from running out of space on the temporary folder where savez stores files. According to this Numpy bug report, a workaround is to set TMPDIR=/path/to/bigger/drive/tmp. In my case, the exception was as OSError rather than the IOError reported there, which I presume is from a change in Python 3. Looks like a fix made it to Numpy 1.12.0.

like image 27
yodavid Avatar answered Nov 14 '22 04:11

yodavid