Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jun 16, 2022

Conversation

carterbox
Copy link
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
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
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
Member Author

The API change which causes this issue was patched upstream.

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 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.

None yet

1 participant