Questions tagged [numpy-memmap]

An advanced numpy.memmap() utility to avoid RAM-size limit and reduce final RAM-footprint ( at a reasonable cost of O/S-cached fileIO mediated via a small-size in-RAM proxy-view window into whole array-data ) Creates and handles a memory-map to an array stored in a binary file on disk.

Creates and handles a memory-map to an array stored in a binary file on disk.

Memory-mapped files are used for arranging access to large non-in-RAM arrays via small proxy-segments of an O/S-cached area of otherwise unmanageably large data files.

Leaving most of the data on disk, without reading the entire file into RAM memory and working with data via smart, moving, O/S-cached window-view into the non-in-RAM big file, enables to escape from both O/S RAM-limits and from adverse side-effects of python's memory management painfull reluctance to release once allocated memory-blocks anytime before the python program termination.

numpy's memmap's are array-like objects.

This differs from Python's mmap module, which uses file-like objects.

101 questions
0
votes
0 answers

numpy.lib.format.open_memmap not storing data

My numpy.lib.format.open_memmap is not storing my data. Code is below. >>> from numpy.lib.format import open_memmap >>> import numpy as np >>> winners = open_memmap("winners.npy", dtype = np.str_, mode='w+', shape=(6,)) >>> winners[0] = "emma" >>>…
0
votes
0 answers

How to use a ndarray of stored ndarrays with memmap as a big ndarray tensor

I recently started to use numpy memmap to link an array in my project since I have a 3 dimensions tensor for a total of 133 billions values for a graph of the dataset I am using as example. I am trying to calculate the heat kernel signature of a…
Ripper346
  • 662
  • 7
  • 22
0
votes
0 answers

Overhead of loading large numpy arrays

My question is simple; and I could not find a resource that answers it. Somewhat similar links are using asarray, on numbers in general, and the most succinct one here. How can I "calculate" the overhead of loading a numpy array into RAM (if there…
emil
  • 194
  • 1
  • 11
0
votes
1 answer

Shuffling and importing few rows of a saved numpy file

I have 2 saved .npy files: X_train - (18873, 224, 224, 3) - 21.2GB Y_train - (18873,) - 148KB X_train is cats and dogs images (cats being in 1st half and dogs in 2nd half, unshuffled) and is mapped with Y_train as 0 and 1. Thus Y_train is…
Rahul Vishwakarma
  • 1,446
  • 2
  • 7
  • 22
0
votes
0 answers

What's the best way to re-order rows in a large binary file?

I have some large data files (32 x VERY BIG) that I would like to concatenate. However, the data were collected in the wrong order, so I need to reorder the rows as well. So far, what I am doing is: # Assume FILE_1 and FILE_2 are paths to the…
0
votes
1 answer

Memory error when sorting a numpy memmap array

I have a numpy-memmap matrix S of size 12 GB. And I'm trying to argsort each row. To do that I have defined another memmap array first_k to save the result. The problem is that a memory error occurs. Here is the code: first_k = np.memmap('first_k',…
asierrayk
  • 43
  • 4
0
votes
1 answer

Numpy memmap first rows random

I'm testing np.memmap out since I need to use it for a large datafile. I'm running python 3.7 on a Windows machine. My test example is very simple. import numpy as np arr = np.ones((10**4, 10), dtype=np.float32) np.save("./arr_test.npy", arr) data =…
Carl Rynegardh
  • 538
  • 1
  • 5
  • 22
0
votes
0 answers

Reading large array with numpy gives zeros

I have a large binary file (~4GB) written in 4byte reals. I am trying to read this file using numpy fromfile as follows. data = np.fromfile(filename, dtype=np.single) Upon inspecting data, I see that all elements are zeros. However when I read the…
0
votes
0 answers

Why does numpy.memmap.flush() not update file in Windows?

I am currently copying/reformatting data from disk into a memmapped-numpy array. I call flush() every ~5000 elements, but the change-date in Windows does not change. dimx = 400000 dimy = 100 dimz = 16 data_in: np.memmap = np.memmap(fname_input,…
I4k
  • 5
  • 2
0
votes
2 answers

numpy memmap runtime error.... 64bits system with 2Gigas limit?

I'm trying to create a large file with numpy memmap big_file = np.memmap(fnamemm, dtype=np.float32, mode='w+', shape=(np.prod(dims[1:]), len_im), order='F') The system is a Windows 10-64bits operating in a 64bits python In [2]:…
senis000
  • 241
  • 2
  • 6
0
votes
1 answer

Python: memmap list of objects become 'None' type inside joblib parallel

I am doing the following: I have a list of tensorflow DNN layers. nn.append(tf.layers.dense(...)) Each of the above list is appended to a list of np.memmap objects. nnList[i] = nn I can access the memmap list and retrieve the tensors. But when try…
Tirtha R
  • 1,148
  • 1
  • 14
  • 24
0
votes
1 answer

Confine dimension of an existing memmap (NumPy)

I have a .dat file containing a large (600000,6,8000) float array generated with numpy.memmap. The third axis represents a date range. At runtime, the user specifies a narrower date range. The result is that I end up slicing along the 3rd dimension…
triphook
  • 2,915
  • 3
  • 25
  • 34
0
votes
1 answer

Lazy version of numpy.unpackbits

I use numpy.memmap to load only the parts of arrays into memory that I need, instead of loading an entire huge array. I would like to do the same with bool arrays. Unfortunately, bool memmap arrays aren't stored economically: according to ls, a bool…
root
  • 1,812
  • 1
  • 12
  • 26
0
votes
0 answers

Why is numpy.memmap initialization so fast?

numpy.memmap initializes with zeros (on systems with POSIX filesystem semantics). Then how can it take only 0.3 seconds to fill a 10 GB file with zeros like this: n = 10000000000 f = np.memmap('tmp.mmap', dtype='uint8', mode='w+', shape=(n,…
root
  • 1,812
  • 1
  • 12
  • 26
0
votes
0 answers

Processing very large images as numpy arrays

I am dealing with images greater than 8 GB in .svs format. Using openslide, I have read them as 1D numpy arrays. Now in order to feed them into an algorithm I need to reshape them into image form for processing the pixel location related…
Suvidha
  • 429
  • 1
  • 6
  • 17