Memory-mapping In Python Using Numpy Error
OUT_DIR = '/media/sf_3dAnalysis/simMatrix/' SIM_FILE = 'similarity.npy' data = np.lib.format.open_memmap(OUT_DIR+SIM_FILE, mode='w+', dtype='float32', shape=(len(filelist),len(f
Solution 1:
I was unable to replicate your error with the example given above.
mmap.error: [Errno 22] Invalid argument
is the error code from the low-level call to the libc mmap
routine see http://www.gnu.org/software/libc/manual/html_node/Memory_002dmapped-I_002fO.html
mmap returns the address of the new mapping, or -1 for an error.
Possible errors include:
EINVAL Either address was unusable, or inconsistent flags were given.
I guess it's an out of memory condition because you are trying to allocate a too large block, that does not fit into the VM virtual memory space.
Solution 2:
So I fixed my problem guys. I created a local copy of the matrix on the Virtual Machine. I then moved that copy to a shared folder. Here is the code illustrating that.
#createlocal copy
data = np.memmap(SIM_FILE, dtype='float32', mode='w+',
shape=(len(filelist),len(filelist)))
#move local copy to shared folder
os.system('mv' + " ~/Desktop/" + SIM_FILE + " " + OUT_DIR )
Post a Comment for "Memory-mapping In Python Using Numpy Error"