Skip to content

No dispatch for <class 'numpy.ndarray'> #7061

Closed
dask/dask
#9545

Description

@gjoseph92

This deserialization error then caused #7060:

2022-09-23 19:01:53,760 - distributed.protocol.core - CRITICAL - Failed to deserialize
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/distributed/protocol/core.py", line 158, in loads
    return msgpack.loads(
  File "msgpack/_unpacker.pyx", line 194, in msgpack._cmsgpack.unpackb
  File "/usr/local/lib/python3.9/site-packages/distributed/protocol/core.py", line 138, in _decode_default
    return merge_and_deserialize(
  File "/usr/local/lib/python3.9/site-packages/distributed/protocol/serialize.py", line 497, in merge_and_deserialize
    return deserialize(header, merged_frames, deserializers=deserializers)
  File "/usr/local/lib/python3.9/site-packages/distributed/protocol/serialize.py", line 426, in deserialize
    return loads(header, frames)
  File "/usr/local/lib/python3.9/site-packages/distributed/protocol/serialize.py", line 58, in dask_loads
    loads = dask_deserialize.dispatch(typ)
  File "/usr/local/lib/python3.9/site-packages/dask/utils.py", line 632, in dispatch
    raise TypeError(f"No dispatch for {cls}")
TypeError: No dispatch for <class 'numpy.ndarray'>

AFAICT, NumPy was installed on the worker. There are plenty of other NumPy keys in memory on the same worker. So I'm not sure why this happened.

Unfortunately, I don't have more information here. Not sure how easily reproducible it is.

Activity

  1. added
    bug
    on Sep 23, 2022
  2. jrbourbeau commented on Sep 23, 2022

    @jrbourbeau
    Member

    Just a shot in the dark, but maybe dask/dask#9181 is related?

  3. gjoseph92 commented on Sep 23, 2022

    @gjoseph92
    CollaboratorAuthor

    I think it's likely that that's it. Thanks for the link!

    Basically, sounds like our serialization registry isn't threadsafe. But we deserialize in threads. Though we do use a threadpool of size 1, we sometimes deserialize in the main thread if the data is small enough. So a large and small NumPy array arriving at the same time would be deserialized concurrently from two threads.

  4. tasansal commented on Oct 4, 2022

    @tasansal

    We are having similar issues in our ETL pipeline. Here is a traceback.

    It is hard to reproduce because it happens at a different time every run.

    dask = 2022.9.2
    distributed = 2022.9.2
    numpy = 1.23.3

    We use a LocalCluster with 16 workers and two threads each on a 32 vCPU VM because our process is I/O bound from the object store (and only scales with processes).

    2022-10-04 01:52:17,376 - distributed.protocol.core - CRITICAL - Failed to deserialize
    Traceback (most recent call last):
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/protocol/core.py", line 158, in loads
        return msgpack.loads(
      File "msgpack/_unpacker.pyx", line 194, in msgpack._cmsgpack.unpackb
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/protocol/core.py", line 138, in _decode_default
        return merge_and_deserialize(
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/protocol/serialize.py", line 497, in merge_and_deserialize
        return deserialize(header, merged_frames, deserializers=deserializers)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/protocol/serialize.py", line 426, in deserialize
        return loads(header, frames)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/protocol/serialize.py", line 58, in dask_loads
        loads = dask_deserialize.dispatch(typ)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/dask/utils.py", line 632, in dispatch
        raise TypeError(f"No dispatch for {cls}")
    TypeError: No dispatch for <class 'numpy.ndarray'>
    2022-10-04 01:52:17,377 - distributed.worker - ERROR - No dispatch for <class 'numpy.ndarray'>
    Traceback (most recent call last):
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/worker.py", line 2031, in gather_dep
        response = await get_data_from_worker(
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/worker.py", line 2820, in get_data_from_worker
        return await retry_operation(_get_data, operation="get_data_from_worker")
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/utils_comm.py", line 383, in retry_operation
        return await retry(
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/utils_comm.py", line 368, in retry
        return await coro()
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/worker.py", line 2800, in _get_data
        response = await send_recv(
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/core.py", line 919, in send_recv
        response = await comm.read(deserializers=deserializers)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/comm/tcp.py", line 254, in read
        msg = await from_frames(
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/comm/utils.py", line 100, in from_frames
        res = _from_frames()
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/comm/utils.py", line 83, in _from_frames
        return protocol.loads(
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/protocol/core.py", line 158, in loads
        return msgpack.loads(
      File "msgpack/_unpacker.pyx", line 194, in msgpack._cmsgpack.unpackb
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/protocol/core.py", line 138, in _decode_default
        return merge_and_deserialize(
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/protocol/serialize.py", line 497, in merge_and_deserialize
        return deserialize(header, merged_frames, deserializers=deserializers)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/protocol/serialize.py", line 426, in deserialize
        return loads(header, frames)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/protocol/serialize.py", line 58, in dask_loads
        loads = dask_deserialize.dispatch(typ)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/dask/utils.py", line 632, in dispatch
        raise TypeError(f"No dispatch for {cls}")
    TypeError: No dispatch for <class 'numpy.ndarray'>
    2022-10-04 01:58:09,491 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,491 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,491 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,492 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,492 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,492 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,493 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,493 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,492 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,493 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,493 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,493 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,494 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,494 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,494 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,494 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,494 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,495 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,495 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,496 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,496 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,497 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,497 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,497 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,497 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,499 - distributed.nanny - ERROR - Worker process died unexpectedly
    /home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/nanny.py:960: RuntimeWarning: coroutine 'PeriodicCallback._run' was never awaited
      loop.run_sync(do_stop)
    RuntimeWarning: Enable tracemalloc to get the object allocation traceback
    2022-10-04 01:58:09,500 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,503 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,511 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,512 - distributed.nanny - ERROR - Worker process died unexpectedly
    2022-10-04 01:58:09,514 - distributed.nanny - ERROR - Worker process died unexpectedly
    Traceback (most recent call last):
      File "/home/username/miniconda3/envs/env/lib/python3.10/multiprocessing/queues.py", line 251, in _feed
        send_bytes(obj)
      File "/home/username/miniconda3/envs/env/lib/python3.10/multiprocessing/connection.py", line 205, in send_bytes
        self._send_bytes(m[offset:offset + size])
      File "/home/username/miniconda3/envs/env/lib/python3.10/multiprocessing/connection.py", line 416, in _send_bytes
        self._send(header + buf)
      File "/home/username/miniconda3/envs/env/lib/python3.10/multiprocessing/connection.py", line 373, in _send
        n = write(self._handle, buf)
    BrokenPipeError: [Errno 32] Broken pipe
    Process Dask Worker process (from Nanny):
    Traceback (most recent call last):
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/psutil/_common.py", line 442, in wrapper
        ret = self._cache[fun]
    AttributeError: 'Process' object has no attribute '_cache'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/username/miniconda3/envs/env/lib/python3.10/multiprocessing/process.py", line 315, in _bootstrap
        self.run()
      File "/home/username/miniconda3/envs/env/lib/python3.10/multiprocessing/process.py", line 108, in run
        self._target(*self._args, **self._kwargs)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/process.py", line 188, in _run
        target(*args, **kwargs)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/nanny.py", line 960, in _run
        loop.run_sync(do_stop)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/tornado/ioloop.py", line 523, in run_sync
        self.start()
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/tornado/platform/asyncio.py", line 215, in start
        self.asyncio_loop.run_forever()
      File "/home/username/miniconda3/envs/env/lib/python3.10/asyncio/base_events.py", line 600, in run_forever
        self._run_once()
      File "/home/username/miniconda3/envs/env/lib/python3.10/asyncio/base_events.py", line 1896, in _run_once
        handle._run()
      File "/home/username/miniconda3/envs/env/lib/python3.10/asyncio/events.py", line 80, in _run
        self._context.run(self._callback, *self._args)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/tornado/ioloop.py", line 687, in <lambda>
        lambda f: self._run_callback(functools.partial(callback, future))
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/tornado/ioloop.py", line 740, in _run_callback
        ret = callback()
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/tornado/ioloop.py", line 764, in _discard_future_result
        future.result()
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/nanny.py", line 953, in _run
        loop.run_sync(run)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/tornado/ioloop.py", line 523, in run_sync
        self.start()
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/tornado/platform/asyncio.py", line 215, in start
        self.asyncio_loop.run_forever()
      File "/home/username/miniconda3/envs/env/lib/python3.10/asyncio/base_events.py", line 600, in run_forever
        self._run_once()
      File "/home/username/miniconda3/envs/env/lib/python3.10/asyncio/base_events.py", line 1896, in _run_once
        handle._run()
      File "/home/username/miniconda3/envs/env/lib/python3.10/asyncio/events.py", line 80, in _run
        self._context.run(self._callback, *self._args)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/tornado/ioloop.py", line 923, in _run
        await val
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/utils.py", line 742, in wrapper
        return await func(*args, **kwargs)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/worker_memory.py", line 171, in memory_monitor
        memory = worker.monitor.get_process_memory()
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/system_monitor.py", line 87, in get_process_memory
        return self.proc.memory_info().rss
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/psutil/_common.py", line 445, in wrapper
        return fun(self)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/psutil/__init__.py", line 1058, in memory_info
        return self._proc.memory_info()
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/psutil/_pslinux.py", line 1642, in wrapper
        return fun(self, *args, **kwargs)
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/psutil/_pslinux.py", line 1874, in memory_info
        with open_binary("%s/%s/statm" % (self._procfs_path, self.pid)) as f:
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/psutil/_common.py", line 727, in open_binary
        return open(fname, "rb", buffering=FILE_READ_BUFFER_SIZE)
    KeyboardInterrupt
    
    Aborted!
    [2022-10-04 01:58:10,414 asyncio] ERROR: Task exception was never retrieved
    future: <Task finished name='Task-4892' coro=<Client._gather.<locals>.wait() done, defined at /home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/client.py:2054> exception=AllExit()>
    Traceback (most recent call last):
      File "/home/username/miniconda3/envs/env/lib/python3.10/site-packages/distributed/client.py", line 2063, in wait
        raise AllExit()
    distributed.client.AllExit
  5. jrbourbeau commented on Oct 4, 2022

    @jrbourbeau
    Member

    Thanks @tasansal. I, or someone else around me, will look into this issue. It's been popping up in a few places.

  6. quasiben commented on Oct 4, 2022

    @quasiben
    Member
  7. zklaus commented on Oct 5, 2022

    @zklaus

    Just to comment that I have put a PR up at dask/dask#9544 that addresses the problem for me locally. It is a very rough draft, but I'd be interested to know if you think that general approach is worth pursuing.

  8. jakirkham commented on Oct 5, 2022

    @jakirkham
    Member

    Could others here please try PR ( dask/dask#9545 ) and report back how that goes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions