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

Compatibility Issue with joblib during serialization of scipy object in Python 3.11.5 #1544

Open
liqunkang opened this issue Feb 14, 2024 · 2 comments

Comments

@liqunkang
Copy link

Hi all,

I recently noticed that there might be an issue for the latest version of joblib to serialize scipy object. For example running the following code:

from joblib import Parallel, delayed
import scipy.stats

def compute_scipy_function(input_data):
    # Simple use of a scipy function in the function to be parallelized
    result = scipy.stats.norm.pdf(input_data, loc=0, scale=1)
    return result

if __name__ == "__main__":
    input_data_list = [1, 2, 3, 4, 5]
    results = Parallel(n_jobs=2)(delayed(compute_scipy_function)(i) for i in input_data_list)
    print("Results:", results)

will show error message:

BrokenProcessPool: A task has failed to un-serialize. Please ensure that the arguments of the function are all picklable.

Incompatible Environment:

Python version: 3.11.5 (main, Sep 11 2023, 08:19:27) [Clang 14.0.6 ]
Platform: macOS-10.16-x86_64-i386-64bit
joblib version: 1.3.2
scipy version: 1.12.0

If I switch back to older version of python (3.10), the script above could run without any issue.

Compatible Environment:

Python version: 3.10.13 (main, Sep 11 2023, 08:39:02) [Clang 14.0.6 ]
Platform: macOS-10.16-x86_64-i386-64bit
joblib version: 1.2.0
scipy version: 1.9.2

I haven't test the other versions of scipy/joblib yet, but I will post further information if required.

Just wondering if you have any idea if this is an issue with how joblib serialize object or it is actually because of some changes in scipy? Any suggestions/solutions would be highly appreciated!

@fcharras
Copy link
Contributor

fcharras commented Apr 3, 2024

I can't reproduce in my environment. Could you please provide the full traceback you have with your minimal reproducer and give more details on your environment (OS/kernel version/cpu architecture) ? I wonder if it could be related to #1545 .

@liqunkang
Copy link
Author

liqunkang commented Apr 3, 2024

Hi, thanks for following up the issue! I just noticed this issue might be related to the ipykernel I am using in the environment. Here's how I reproduce the issue on my MacBook Pro. The environment info is as follows:

Operating System: Darwin
Kernel Version: 23.4.0
CPU Architecture: x86_64
Python Version: 3.11.5
Platform: macOS-10.16-x86_64-i386-64bit

I created a new env in anaconda3 called test2 for python version 3.11.5 with the following packages as the initial configuration:

  bzip2              pkgs/main/osx-64::bzip2-1.0.8-h6c40b1e_5 
  ca-certificates    pkgs/main/osx-64::ca-certificates-2024.3.11-hecd8cb5_0 
  libffi             pkgs/main/osx-64::libffi-3.4.4-hecd8cb5_0 
  ncurses            pkgs/main/osx-64::ncurses-6.4-hcec6c5f_0 
  openssl            pkgs/main/osx-64::openssl-3.0.13-hca72f7f_0 
  pip                pkgs/main/osx-64::pip-23.3.1-py311hecd8cb5_0 
  python             pkgs/main/osx-64::python-3.11.5-hf27a42d_0 
  readline           pkgs/main/osx-64::readline-8.2-hca72f7f_0 
  setuptools         pkgs/main/osx-64::setuptools-68.2.2-py311hecd8cb5_0 
  sqlite             pkgs/main/osx-64::sqlite-3.41.2-h6c40b1e_0 
  tk                 pkgs/main/osx-64::tk-8.6.12-h5d9f67b_0 
  tzdata             pkgs/main/noarch::tzdata-2024a-h04d1e81_0 
  wheel              pkgs/main/osx-64::wheel-0.41.2-py311hecd8cb5_0 
  xz                 pkgs/main/osx-64::xz-5.4.6-h6c40b1e_0 
  zlib               pkgs/main/osx-64::zlib-1.2.13-h4dc903c_0 

Then with joblib and scipy installed, the full list of the packages became as follows:

blas                      1.0                         mkl  
bzip2                     1.0.8                h6c40b1e_5  
ca-certificates           2024.3.11            hecd8cb5_0  
intel-openmp              2023.1.0         ha357a0b_43548  
joblib                    1.2.0           py311hecd8cb5_0  
libcxx                    14.0.6               h9765a3e_0  
libffi                    3.4.4                hecd8cb5_0  
libgfortran               5.0.0           11_3_0_hecd8cb5_28  
libgfortran5              11.3.0              h9dfd629_28  
llvm-openmp               14.0.6               h0dcd299_0  
mkl                       2023.1.0         h8e150cf_43560  
mkl-service               2.4.0           py311h6c40b1e_1  
mkl_fft                   1.3.8           py311h6c40b1e_0  
mkl_random                1.2.4           py311ha357a0b_0  
ncurses                   6.4                  hcec6c5f_0  
numpy                     1.26.4          py311h728a8a3_0  
numpy-base                1.26.4          py311h53bf9ac_0  
openssl                   3.0.13               hca72f7f_0  
pip                       23.3.1          py311hecd8cb5_0  
python                    3.11.5               hf27a42d_0  
readline                  8.2                  hca72f7f_0  
scipy                     1.12.0          py311h224febf_0  
setuptools                68.2.2          py311hecd8cb5_0  
sqlite                    3.41.2               h6c40b1e_0  
tbb                       2021.8.0             ha357a0b_0  
tk                        8.6.12               h5d9f67b_0  
tzdata                    2024a                h04d1e81_0  
wheel                     0.41.2          py311hecd8cb5_0  
xz                        5.4.6                h6c40b1e_0  
zlib                      1.2.13               h4dc903c_0  

If I just run the script in a .py file without any other package installed, I got the correct output without any issue.

from joblib import Parallel, delayed
import scipy.stats

def compute_scipy_function(input_data):
    # Simple use of a scipy function in the function to be parallelized
    result = scipy.stats.norm.pdf(input_data, loc=0, scale=1)
    return result

if __name__ == "__main__":
    input_data_list = [1, 2, 3, 4, 5]
    results = Parallel(n_jobs=2)(delayed(compute_scipy_function)(i) for i in input_data_list)
    print("Results:", results)

Output:

Results: [0.24197072451914337, 0.05399096651318806, 0.0044318484119380075, 0.00013383022576488537, 1.4867195147342979e-06]

Then I installed the ipykernal in this environment, with a full list of packages like this:

appnope                   0.1.2           py311hecd8cb5_1001  
asttokens                 2.0.5              pyhd3eb1b0_0  
blas                      1.0                         mkl  
bzip2                     1.0.8                h6c40b1e_5  
ca-certificates           2024.3.11            hecd8cb5_0  
comm                      0.2.1           py311hecd8cb5_0  
debugpy                   1.6.7           py311hcec6c5f_0  
decorator                 5.1.1              pyhd3eb1b0_0  
executing                 0.8.3              pyhd3eb1b0_0  
intel-openmp              2023.1.0         ha357a0b_43548  
ipykernel                 6.28.0          py311hecd8cb5_0  
ipython                   8.20.0          py311hecd8cb5_0  
jedi                      0.18.1          py311hecd8cb5_1  
joblib                    1.2.0           py311hecd8cb5_0  
jupyter_client            8.6.0           py311hecd8cb5_0  
jupyter_core              5.5.0           py311hecd8cb5_0  
libcxx                    14.0.6               h9765a3e_0  
libffi                    3.4.4                hecd8cb5_0  
libgfortran               5.0.0           11_3_0_hecd8cb5_28  
libgfortran5              11.3.0              h9dfd629_28  
libsodium                 1.0.18               h1de35cc_0  
llvm-openmp               14.0.6               h0dcd299_0  
matplotlib-inline         0.1.6           py311hecd8cb5_0  
mkl                       2023.1.0         h8e150cf_43560  
mkl-service               2.4.0           py311h6c40b1e_1  
mkl_fft                   1.3.8           py311h6c40b1e_0  
mkl_random                1.2.4           py311ha357a0b_0  
ncurses                   6.4                  hcec6c5f_0  
nest-asyncio              1.6.0           py311hecd8cb5_0  
numpy                     1.26.4          py311h728a8a3_0  
numpy-base                1.26.4          py311h53bf9ac_0  
openssl                   3.0.13               hca72f7f_0  
packaging                 23.2            py311hecd8cb5_0  
parso                     0.8.3              pyhd3eb1b0_0  
pexpect                   4.8.0              pyhd3eb1b0_3  
pip                       23.3.1          py311hecd8cb5_0  
platformdirs              3.10.0          py311hecd8cb5_0  
prompt-toolkit            3.0.43          py311hecd8cb5_0  
prompt_toolkit            3.0.43               hd3eb1b0_0  
psutil                    5.9.0           py311h6c40b1e_0  
ptyprocess                0.7.0              pyhd3eb1b0_2  
pure_eval                 0.2.2              pyhd3eb1b0_0  
pygments                  2.15.1          py311hecd8cb5_1  
python                    3.11.5               hf27a42d_0  
python-dateutil           2.8.2              pyhd3eb1b0_0  
pyzmq                     25.1.2          py311hcec6c5f_0  
readline                  8.2                  hca72f7f_0  
scipy                     1.12.0          py311h224febf_0  
setuptools                68.2.2          py311hecd8cb5_0  
six                       1.16.0             pyhd3eb1b0_1  
sqlite                    3.41.2               h6c40b1e_0  
stack_data                0.2.0              pyhd3eb1b0_0  
tbb                       2021.8.0             ha357a0b_0  
tk                        8.6.12               h5d9f67b_0  
tornado                   6.3.3           py311h6c40b1e_0  
traitlets                 5.7.1           py311hecd8cb5_0  
tzdata                    2024a                h04d1e81_0  
wcwidth                   0.2.5              pyhd3eb1b0_0  
wheel                     0.41.2          py311hecd8cb5_0  
xz                        5.4.6                h6c40b1e_0  
zeromq                    4.3.5                hcec6c5f_0  
zlib                      1.2.13               h4dc903c_0 

Then if I run the cell in VS Code Jupyter notebook or the .py file directly, there should be error message like this:

Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
OSError: [Errno 9] Bad file descriptor

Current thread 0x00007ff853081100 (most recent call first):
  <no Python frame>
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
OSError: [Errno 9] Bad file descriptor

Current thread 0x00007ff853081100 (most recent call first):
  <no Python frame>
exception calling callback for <Future at 0x103898b10 state=finished raised BrokenProcessPool>
joblib.externals.loky.process_executor._RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/loky/process_executor.py", line 391, in _process_worker
    call_item = call_queue.get(block=True, timeout=timeout)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/multiprocessing/queues.py", line 122, in get
    return _ForkingPickler.loads(res)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/cloudpickle/cloudpickle.py", line 649, in subimport
    __import__(name)
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/scipy/__init__.py", line 67, in <module>
    from scipy._lib import _pep440
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/scipy/_lib/__init__.py", line 12, in <module>
    from scipy._lib._testutils import PytestTester
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/scipy/_lib/_testutils.py", line 21, in <module>
    _tags = list(sys_tags())
            ^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/packaging/tags.py", line 543, in sys_tags
    yield from cpython_tags(warn=warn)
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/packaging/tags.py", line 212, in cpython_tags
    platforms = list(platforms or platform_tags())
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/packaging/tags.py", line 400, in mac_platforms
    version_str = subprocess.run(
                  ^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/Users/kang/opt/anaconda3/envs/test2/bin/python', '-sS', '-c', 'import platform; print(platform.mac_ver()[0])']' returned non-zero exit status 1.
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/loky/_base.py", line 26, in _invoke_callbacks
    callback(self)
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py", line 385, in __call__
    self.parallel.dispatch_next()
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py", line 834, in dispatch_next
    if not self.dispatch_one_batch(self._original_iterator):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py", line 901, in dispatch_one_batch
    self._dispatch(tasks)
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py", line 819, in _dispatch
    job = self._backend.apply_async(batch, callback=cb)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/_parallel_backends.py", line 556, in apply_async
    future = self._workers.submit(SafeFunction(func))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/loky/reusable_executor.py", line 176, in submit
    return super().submit(fn, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/loky/process_executor.py", line 1129, in submit
    raise self._flags.broken
joblib.externals.loky.process_executor.BrokenProcessPool: A task has failed to un-serialize. Please ensure that the arguments of the function are all picklable.
joblib.externals.loky.process_executor._RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/loky/process_executor.py", line 391, in _process_worker
    call_item = call_queue.get(block=True, timeout=timeout)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/multiprocessing/queues.py", line 122, in get
    return _ForkingPickler.loads(res)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/cloudpickle/cloudpickle.py", line 649, in subimport
    __import__(name)
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/scipy/__init__.py", line 67, in <module>
    from scipy._lib import _pep440
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/scipy/_lib/__init__.py", line 12, in <module>
    from scipy._lib._testutils import PytestTester
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/scipy/_lib/_testutils.py", line 21, in <module>
    _tags = list(sys_tags())
            ^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/packaging/tags.py", line 543, in sys_tags
    yield from cpython_tags(warn=warn)
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/packaging/tags.py", line 212, in cpython_tags
    platforms = list(platforms or platform_tags())
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/packaging/tags.py", line 400, in mac_platforms
    version_str = subprocess.run(
                  ^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/Users/kang/opt/anaconda3/envs/test2/bin/python', '-sS', '-c', 'import platform; print(platform.mac_ver()[0])']' returned non-zero exit status 1.
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/kang/Downloads/MyPlayground/2024/04/20240403/joblib testing.py", line 11, in <module>
    results = Parallel(n_jobs=2)(delayed(compute_scipy_function)(i) for i in input_data_list)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py", line 1098, in __call__
    self.retrieve()
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py", line 975, in retrieve
    self._output.extend(job.get(timeout=self.timeout))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/_parallel_backends.py", line 567, in wrap_future_result
    return future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/loky/_base.py", line 26, in _invoke_callbacks
    callback(self)
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py", line 385, in __call__
    self.parallel.dispatch_next()
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py", line 834, in dispatch_next
    if not self.dispatch_one_batch(self._original_iterator):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py", line 901, in dispatch_one_batch
    self._dispatch(tasks)
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py", line 819, in _dispatch
    job = self._backend.apply_async(batch, callback=cb)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/_parallel_backends.py", line 556, in apply_async
    future = self._workers.submit(SafeFunction(func))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/loky/reusable_executor.py", line 176, in submit
    return super().submit(fn, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/loky/process_executor.py", line 1129, in submit
    raise self._flags.broken
joblib.externals.loky.process_executor.BrokenProcessPool: A task has failed to un-serialize. Please ensure that the arguments of the function are all picklable.

And the traceback from the Jupyter notebook:

{
	"name": "BrokenProcessPool",
	"message": "A task has failed to un-serialize. Please ensure that the arguments of the function are all picklable.",
	"stack": "---------------------------------------------------------------------------
_RemoteTraceback                          Traceback (most recent call last)
_RemoteTraceback: 
\"\"\"
Traceback (most recent call last):
  File \"/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/loky/process_executor.py\", line 391, in _process_worker
    call_item = call_queue.get(block=True, timeout=timeout)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/multiprocessing/queues.py\", line 122, in get
    return _ForkingPickler.loads(res)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/cloudpickle/cloudpickle.py\", line 649, in subimport
    __import__(name)
  File \"/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/scipy/__init__.py\", line 67, in <module>
    from scipy._lib import _pep440
  File \"/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/scipy/_lib/__init__.py\", line 12, in <module>
    from scipy._lib._testutils import PytestTester
  File \"/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/scipy/_lib/_testutils.py\", line 21, in <module>
    _tags = list(sys_tags())
            ^^^^^^^^^^^^^^^^
  File \"/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/packaging/tags.py\", line 543, in sys_tags
    yield from cpython_tags(warn=warn)
  File \"/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/packaging/tags.py\", line 212, in cpython_tags
    platforms = list(platforms or platform_tags())
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/site-packages/packaging/tags.py\", line 400, in mac_platforms
    version_str = subprocess.run(
                  ^^^^^^^^^^^^^^^
  File \"/Users/kang/opt/anaconda3/envs/test2/lib/python3.11/subprocess.py\", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/Users/kang/opt/anaconda3/envs/test2/bin/python', '-sS', '-c', 'import platform; print(platform.mac_ver()[0])']' returned non-zero exit status 1.
\"\"\"

The above exception was the direct cause of the following exception:

BrokenProcessPool                         Traceback (most recent call last)
Cell In[1], line 11
      9 if __name__ == \"__main__\":
     10     input_data_list = [1, 2, 3, 4, 5]
---> 11     results = Parallel(n_jobs=2)(delayed(compute_scipy_function)(i) for i in input_data_list)
     12     print(\"Results:\", results)

File ~/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py:1098, in Parallel.__call__(self, iterable)
   1095     self._iterating = False
   1097 with self._backend.retrieval_context():
-> 1098     self.retrieve()
   1099 # Make sure that we get a last message telling us we are done
   1100 elapsed_time = time.time() - self._start_time

File ~/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py:975, in Parallel.retrieve(self)
    973 try:
    974     if getattr(self._backend, 'supports_timeout', False):
--> 975         self._output.extend(job.get(timeout=self.timeout))
    976     else:
    977         self._output.extend(job.get())

File ~/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/_parallel_backends.py:567, in LokyBackend.wrap_future_result(future, timeout)
    564 \"\"\"Wrapper for Future.result to implement the same behaviour as
    565 AsyncResults.get from multiprocessing.\"\"\"
    566 try:
--> 567     return future.result(timeout=timeout)
    568 except CfTimeoutError as e:
    569     raise TimeoutError from e

File ~/opt/anaconda3/envs/test2/lib/python3.11/concurrent/futures/_base.py:456, in Future.result(self, timeout)
    454     raise CancelledError()
    455 elif self._state == FINISHED:
--> 456     return self.__get_result()
    457 else:
    458     raise TimeoutError()

File ~/opt/anaconda3/envs/test2/lib/python3.11/concurrent/futures/_base.py:401, in Future.__get_result(self)
    399 if self._exception:
    400     try:
--> 401         raise self._exception
    402     finally:
    403         # Break a reference cycle with the exception in self._exception
    404         self = None

File ~/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/loky/_base.py:26, in Future._invoke_callbacks(self)
     24 for callback in self._done_callbacks:
     25     try:
---> 26         callback(self)
     27     except BaseException:
     28         LOGGER.exception(f'exception calling callback for {self!r}')

File ~/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py:385, in BatchCompletionCallBack.__call__(self, out)
    383 with self.parallel._lock:
    384     if self.parallel._original_iterator is not None:
--> 385         self.parallel.dispatch_next()

File ~/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py:834, in Parallel.dispatch_next(self)
    826 def dispatch_next(self):
    827     \"\"\"Dispatch more data for parallel processing
    828 
    829     This method is meant to be called concurrently by the multiprocessing
   (...)
    832 
    833     \"\"\"
--> 834     if not self.dispatch_one_batch(self._original_iterator):
    835         self._iterating = False
    836         self._original_iterator = None

File ~/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py:901, in Parallel.dispatch_one_batch(self, iterator)
    899     return False
    900 else:
--> 901     self._dispatch(tasks)
    902     return True

File ~/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/parallel.py:819, in Parallel._dispatch(self, batch)
    817 with self._lock:
    818     job_idx = len(self._jobs)
--> 819     job = self._backend.apply_async(batch, callback=cb)
    820     # A job can complete so quickly than its callback is
    821     # called before we get here, causing self._jobs to
    822     # grow. To ensure correct results ordering, .insert is
    823     # used (rather than .append) in the following line
    824     self._jobs.insert(job_idx, job)

File ~/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/_parallel_backends.py:556, in LokyBackend.apply_async(self, func, callback)
    554 def apply_async(self, func, callback=None):
    555     \"\"\"Schedule a func to be run\"\"\"
--> 556     future = self._workers.submit(SafeFunction(func))
    557     future.get = functools.partial(self.wrap_future_result, future)
    558     if callback is not None:

File ~/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/loky/reusable_executor.py:176, in _ReusablePoolExecutor.submit(self, fn, *args, **kwargs)
    174 def submit(self, fn, *args, **kwargs):
    175     with self._submit_resize_lock:
--> 176         return super().submit(fn, *args, **kwargs)

File ~/opt/anaconda3/envs/test2/lib/python3.11/site-packages/joblib/externals/loky/process_executor.py:1129, in ProcessPoolExecutor.submit(self, fn, *args, **kwargs)
   1127 with self._flags.shutdown_lock:
   1128     if self._flags.broken is not None:
-> 1129         raise self._flags.broken
   1130     if self._flags.shutdown:
   1131         raise ShutdownExecutorError(
   1132             'cannot schedule new futures after shutdown')

BrokenProcessPool: A task has failed to un-serialize. Please ensure that the arguments of the function are all picklable."
}

I hope the information above could be of help. Thank you very much!

I can't reproduce in my environment. Could you please provide the full traceback you have with your minimal reproducer and give more details on your environment (OS/kernel version/cpu architecture) ? I wonder if it could be related to #1545 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants