Skip to content

BUG: distribute_jobs no longer works on Win/MacOS#585

Merged
carterbox merged 1 commit intotomopy:masterfrom
carterbox:memoryview-pickle
Jun 16, 2022
Merged

BUG: distribute_jobs no longer works on Win/MacOS#585
carterbox merged 1 commit intotomopy:masterfrom
carterbox:memoryview-pickle

Conversation

@carterbox
Copy link
Copy Markdown
Member

@carterbox carterbox commented May 26, 2022

    def dump(obj, file, protocol=None):
        '''Replacement for pickle.dump() using ForkingPickler.'''
>       ForkingPickler(file, protocol).dump(obj)
E       TypeError: cannot pickle 'memoryview' object

This error is occuring on the conda-forge feedstock OSX builds. Research tells me that it is caused by trying to pass memory views instead of numpy arrays to the multiprocessing distrbute_jobs function.

@carterbox carterbox added Windows Requests for Windows support macOS Requests for macOS support labels May 26, 2022
@carterbox carterbox changed the title BUG: Prevent pickling warnings from multiprocessing on osx BUG: distribute_jobs no longer works on Win/MacOS May 26, 2022
@carterbox
Copy link
Copy Markdown
Member Author

carterbox commented May 26, 2022

A recent patch to the numpy library (1.22.4), changed the behavior of np.from_buffer(), but only on non-linux platforms? On these platforms, the "base" attribute of a shared array is now memory view instead of the same as thee array before from_buffer is applied.

The affected code is here:

shared_obj = mp.RawArray(ctype, arr.size)
# create numpy array from shared object
# shared_arr = np.ctypeslib.as_array(shared_obj)
shared_arr = np.frombuffer(shared_obj, dtype=arr.dtype)
shared_arr = np.reshape(shared_arr, arr.shape)

where shared_arr.base is now a memoryview instead of a mp.RawArray.

@carterbox
Copy link
Copy Markdown
Member Author

@michael-sutherland, do you have any opinions about whether we should refactor the TomoPy implementation of distribute_jobs or pursue the patch in NumPy? I don't really understand the reasons/motivations behind either case.

carterbox added a commit to carterbox/tomopy that referenced this pull request May 31, 2022
Also removes openblas varirant pinning.
Closes tomopy#585
@carterbox
Copy link
Copy Markdown
Member Author

The API change which causes this issue was patched upstream.

@carterbox carterbox force-pushed the memoryview-pickle branch from ca55f87 to f0dd852 Compare June 16, 2022 23:14
A change in numpy=1.22.4 caused the following error:

    def dump(obj, file, protocol=None):
        '''Replacement for pickle.dump() using ForkingPickler.'''
>       ForkingPickler(file, protocol).dump(obj)
E       TypeError: cannot pickle 'memoryview' object
@carterbox carterbox force-pushed the memoryview-pickle branch from f0dd852 to 1b65456 Compare June 16, 2022 23:15
@carterbox carterbox marked this pull request as ready for review June 16, 2022 23:15
@carterbox carterbox merged commit 21ba228 into tomopy:master Jun 16, 2022
@carterbox carterbox deleted the memoryview-pickle branch June 16, 2022 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macOS Requests for macOS support Windows Requests for Windows support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant