Skip to content

distributed workers on kubernetes require dill #3606

Closed

Description

@jrwalk

Hello! I'm starting up running distributed Dask on a kubernetes cluster, and have been running into serialization issues.

Kubernetes version: 1.15.10 - using image daskdev/dask:2.11.0
Dask version: 2.11.0
Distributed version: 2.11.0

When triggering a process on a dask.bag we're hitting errors with serialization, specifically a ModuleNotFoundError for the dill module.

This resolves itself if we install dill on the workers - however, from all the documentation I can find dask removed dependencies on dill in favor of cloudpickle some time ago. Both the client and the workers/scheduler have cloudpickle==1.3.0 installed, so this is definitely available. Is there some hidden dependency on 'dill that I'm missing, or do I potentially have the workers configured wrong?

Other processes run correctly, and include similar steps - the only non-dask steps are calling lambda functions with .map.

Activity

  1. lesteve commented on Mar 20, 2020

    @lesteve
    Member

    dill was removed in 6dc1f3f (November 2015) which was in distributed 1.4 so it seems like you are using an old version of distributed on your workers for some reason.

    You can use this to verify which versions of distributed you are using on your workers and check that they are the same than the one on your scheduler and on your client:

    client.get_versions(check=True)
  2. jrwalk commented on Mar 20, 2020

    @jrwalk
    Author

    Right, I'd seen that dill was removed a while back. Output of get_versions below (short version, does seem to be correctly seeing distributed==2.11.0 as expected):

    {
      "scheduler": {
        "host": [
          [
            "python",
            "3.7.4.final.0"
          ],
          [
            "python-bits",
            64
          ],
          [
            "OS",
            "Linux"
          ],
          [
            "OS-release",
            "4.9.0-11-amd64"
          ],
          [
            "machine",
            "x86_64"
          ],
          [
            "processor",
            ""
          ],
          [
            "byteorder",
            "little"
          ],
          [
            "LC_ALL",
            "C.UTF-8"
          ],
          [
            "LANG",
            "C.UTF-8"
          ]
        ],
        "packages": {
          "dask": "2.11.0",
          "distributed": "2.11.0",
          "msgpack": "1.0.0",
          "cloudpickle": "1.3.0",
          "tornado": "6.0.3",
          "toolz": "0.10.0",
          "numpy": "1.18.1",
          "lz4": "3.0.2",
          "blosc": "1.8.3"
        }
      },
      "workers": {
        "tcp://<ip>:33043": {
          "host": [
            [
              "python",
              "3.7.4.final.0"
            ],
            [
              "python-bits",
              64
            ],
            [
              "OS",
              "Linux"
            ],
            [
              "OS-release",
              "4.9.0-11-amd64"
            ],
            [
              "machine",
              "x86_64"
            ],
            [
              "processor",
              ""
            ],
            [
              "byteorder",
              "little"
            ],
            [
              "LC_ALL",
              "C.UTF-8"
            ],
            [
              "LANG",
              "C.UTF-8"
            ]
          ],
          "packages": {
            "dask": "2.11.0",
            "distributed": "2.11.0",
            "msgpack": "1.0.0",
            "cloudpickle": "1.3.0",
            "tornado": "6.0.3",
            "toolz": "0.10.0",
            "numpy": "1.18.1",
            "lz4": "3.0.2",
            "blosc": "1.8.3"
          }
        },
        "tcp://<ip>8:36375": {
          "host": [
            [
              "python",
              "3.7.4.final.0"
            ],
            [
              "python-bits",
              64
            ],
            [
              "OS",
              "Linux"
            ],
            [
              "OS-release",
              "4.9.0-11-amd64"
            ],
            [
              "machine",
              "x86_64"
            ],
            [
              "processor",
              ""
            ],
            [
              "byteorder",
              "little"
            ],
            [
              "LC_ALL",
              "C.UTF-8"
            ],
            [
              "LANG",
              "C.UTF-8"
            ]
          ],
          "packages": {
            "dask": "2.11.0",
            "distributed": "2.11.0",
            "msgpack": "1.0.0",
            "cloudpickle": "1.3.0",
            "tornado": "6.0.3",
            "toolz": "0.10.0",
            "numpy": "1.18.1",
            "lz4": "3.0.2",
            "blosc": "1.8.3"
          }
        }
      },
      "client": {
        "host": [
          [
            "python",
            "3.7.5.final.0"
          ],
          [
            "python-bits",
            64
          ],
          [
            "OS",
            "Linux"
          ],
          [
            "OS-release",
            "4.19.76-linuxkit"
          ],
          [
            "machine",
            "x86_64"
          ],
          [
            "processor",
            "x86_64"
          ],
          [
            "byteorder",
            "little"
          ],
          [
            "LC_ALL",
            "None"
          ],
          [
            "LANG",
            "en_US.UTF-8"
          ]
        ],
        "packages": {
          "dask": "2.11.0",
          "distributed": "2.11.0",
          "msgpack": "1.0.0",
          "cloudpickle": "1.3.0",
          "tornado": "6.0.3",
          "toolz": "0.10.0",
          "numpy": "1.18.1",
          "lz4": "3.0.2",
          "blosc": "1.8.3"
        }
      }
    }
    
  3. jrwalk commented on Mar 20, 2020

    @jrwalk
    Author

    conda list on the worker nodes via kubernetes is also consistent with this (as expected since it's just running the stock dask:2.11.0 image), thus my confusion :)

  4. lesteve commented on Mar 20, 2020

    @lesteve
    Member

    Weird, maybe posting the full stack-trace you get with the dill ImportError could be useful.

  5. jrwalk commented on Mar 20, 2020

    @jrwalk
    Author

    from the dask worker logs:

    distributed.worker - ERROR - No module named 'dill' Traceback (most recent call last): File "/opt/conda/lib/python3.7/site-packages/distributed/worker.py", line 931, in handle_scheduler comm, every_cycle=[self.ensure_communicating, self.ensure_computing] File "/opt/conda/lib/python3.7/site-packages/distributed/core.py", line 456, in handle_stream msgs = await comm.read() File "/opt/conda/lib/python3.7/site-packages/distributed/comm/tcp.py", line 212, in read frames, deserialize=self.deserialize, deserializers=deserializers File "/opt/conda/lib/python3.7/site-packages/distributed/comm/utils.py", line 75, in from_frames res = _from_frames() File "/opt/conda/lib/python3.7/site-packages/distributed/comm/utils.py", line 61, in _from_frames frames, deserialize=deserialize, deserializers=deserializers File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/core.py", line 124, in loads value = _deserialize(head, fs, deserializers=deserializers) File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 255, in deserialize deserializers=deserializers, File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 255, in deserialize deserializers=deserializers, File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 255, in deserialize deserializers=deserializers, [Previous line repeated 2 more times] File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 268, in deserialize return loads(header, frames) File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 62, in pickle_loads return pickle.loads(b"".join(frames)) File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/pickle.py", line 59, in loads return pickle.loads(x) ModuleNotFoundError: No module named 'dill'
    
  6. jrwalk commented on Mar 20, 2020

    @jrwalk
    Author

    and the kubernetes pod logs:

    tornado.application - ERROR - Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOLoop object at 0x7f7b8ea072d0>>, <Task finished coro=<Worker.handle_scheduler() done, defined at /opt/conda/lib/python3.7/site-packages/distributed/worker.py:928> exception=ModuleNotFoundError("No module named 'dill'")>)
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.7/site-packages/tornado/ioloop.py", line 743, in _run_callback
        ret = callback()
      File "/opt/conda/lib/python3.7/site-packages/tornado/ioloop.py", line 767, in _discard_future_result
        future.result()
      File "/opt/conda/lib/python3.7/site-packages/distributed/worker.py", line 931, in handle_scheduler
        comm, every_cycle=[self.ensure_communicating, self.ensure_computing]
      File "/opt/conda/lib/python3.7/site-packages/distributed/core.py", line 456, in handle_stream
        msgs = await comm.read()
      File "/opt/conda/lib/python3.7/site-packages/distributed/comm/tcp.py", line 212, in read
        frames, deserialize=self.deserialize, deserializers=deserializers
      File "/opt/conda/lib/python3.7/site-packages/distributed/comm/utils.py", line 75, in from_frames
        res = _from_frames()
      File "/opt/conda/lib/python3.7/site-packages/distributed/comm/utils.py", line 61, in _from_frames
        frames, deserialize=deserialize, deserializers=deserializers
      File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/core.py", line 124, in loads
        value = _deserialize(head, fs, deserializers=deserializers)
      File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 255, in deserialize
        deserializers=deserializers,
      File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 255, in deserialize
        deserializers=deserializers,
      File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 255, in deserialize
        deserializers=deserializers,
      [Previous line repeated 2 more times]
      File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 268, in deserialize
        return loads(header, frames)
      File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 62, in pickle_loads
        return pickle.loads(b"".join(frames))
      File "/opt/conda/lib/python3.7/site-packages/distributed/protocol/pickle.py", line 59, in loads
        return pickle.loads(x)
    ModuleNotFoundError: No module named 'dill'
    
  7. mrocklin commented on Mar 20, 2020

    @mrocklin
    Member
  8. jrwalk commented on Mar 20, 2020

    @jrwalk
    Author

    The whole dask cluster was only created this week, so who knows where it'd come up with an old worker :/

    Full environment list (from conda list on the k8s pod):

    # packages in environment at /opt/conda:
    #
    # Name                    Version                   Build  Channel
    _libgcc_mutex             0.1                        main  
    asn1crypto                1.0.1                    py37_0  
    attrs                     19.3.0                   pypi_0    pypi
    beautifulsoup4            4.8.2                    pypi_0    pypi
    blas                      2.14                   openblas    conda-forge
    blosc                     1.17.1               he1b5a44_0    conda-forge
    bokeh                     1.4.0                    py37_0    conda-forge
    boltons                   20.0.0                   pypi_0    pypi
    boto3                     1.12.25                  pypi_0    pypi
    botocore                  1.15.25                  pypi_0    pypi
    ca-certificates           2019.11.28           hecc5488_0    conda-forge
    certifi                   2019.11.28               py37_0    conda-forge
    cffi                      1.12.3           py37h2e261b9_0  
    chardet                   3.0.4                 py37_1003  
    click                     7.0                        py_0    conda-forge
    cloudpickle               1.3.0                      py_0    conda-forge
    conda                     4.8.2                    py37_0    conda-forge
    conda-package-handling    1.6.0            py37h7b6447c_0  
    cryptography              2.7              py37h1ba5d50_0  
    cytoolz                   0.10.1           py37h516909a_0    conda-forge
    dask                      2.11.0                     py_0    conda-forge
    dask-core                 2.11.0                     py_0    conda-forge
    dask-glm                  0.2.0                    pypi_0    pypi
    dask-ml                   1.2.0                    pypi_0    pypi
    distributed               2.11.0                   py37_0    conda-forge
    docutils                  0.15.2                   pypi_0    pypi
    face                      20.1.1                   pypi_0    pypi
    freetype                  2.10.0               he983fc9_1    conda-forge
    fsspec                    0.6.2                      py_0    conda-forge
    glom                      19.10.0                  pypi_0    pypi
    heapdict                  1.0.1                      py_0    conda-forge
    idna                      2.8                      py37_0  
    jinja2                    2.11.1                     py_0    conda-forge
    jmespath                  0.9.5                    pypi_0    pypi
    joblib                    0.14.1                   pypi_0    pypi
    jpeg                      9c                h14c3975_1001    conda-forge
    libblas                   3.8.0               14_openblas    conda-forge
    libcblas                  3.8.0               14_openblas    conda-forge
    libedit                   3.1.20181209         hc058e9b_0  
    libffi                    3.2.1                hd88cf55_4  
    libgcc-ng                 9.1.0                hdf63c60_0  
    libgfortran-ng            7.3.0                hdf63c60_5    conda-forge
    liblapack                 3.8.0               14_openblas    conda-forge
    liblapacke                3.8.0               14_openblas    conda-forge
    libopenblas               0.3.7                h5ec1e0e_6    conda-forge
    libpng                    1.6.37               hed695b0_0    conda-forge
    libstdcxx-ng              9.1.0                hdf63c60_0  
    libtiff                   4.1.0                hc3755c2_3    conda-forge
    llvmlite                  0.31.0                   pypi_0    pypi
    locket                    0.2.0                      py_2    conda-forge
    lz4                       3.0.2            py37hd79334b_0    conda-forge
    lz4-c                     1.8.3             he1b5a44_1001    conda-forge
    markupsafe                1.1.1            py37h516909a_0    conda-forge
    msgpack-python            1.0.0            py37hc9558a2_0    conda-forge
    multipledispatch          0.6.0                    pypi_0    pypi
    ncurses                   6.1                  he6710b0_1  
    nomkl                     3.0                           0  
    numba                     0.48.0                   pypi_0    pypi
    numpy                     1.18.1           py37h95a1406_0    conda-forge
    olefile                   0.46                       py_0    conda-forge
    openssl                   1.1.1d               h516909a_0    conda-forge
    packaging                 20.1                       py_0    conda-forge
    pandas                    1.0.1            py37hb3f55d8_0    conda-forge
    partd                     1.1.0                      py_0    conda-forge
    pillow                    7.0.0            py37hb39fc2d_0  
    pip                       19.2.3                   py37_0  
    psutil                    5.7.0            py37h516909a_0    conda-forge
    pyarrow                   0.16.0                   pypi_0    pypi
    pycosat                   0.6.3            py37h14c3975_0  
    pycparser                 2.19                     py37_0  
    pyopenssl                 19.0.0                   py37_0  
    pyparsing                 2.4.6                      py_0    conda-forge
    pysocks                   1.7.1                    py37_0  
    python                    3.7.4                h265db76_1  
    python-blosc              1.8.3            py37hb3f55d8_0    conda-forge
    python-dateutil           2.8.1                      py_0    conda-forge
    pytz                      2019.3                     py_0    conda-forge
    pyyaml                    5.1.2            py37h516909a_0    conda-forge
    readline                  7.0                  h7b6447c_5  
    requests                  2.22.0                   py37_0  
    ruamel_yaml               0.15.46          py37h14c3975_0  
    s3fs                      0.4.0                    pypi_0    pypi
    s3transfer                0.3.3                    pypi_0    pypi
    scikit-learn              0.22.2.post1             pypi_0    pypi
    scipy                     1.4.1                    pypi_0    pypi
    setuptools                41.4.0                   py37_0  
    six                       1.12.0                   py37_0  
    sortedcontainers          2.1.0                      py_0    conda-forge
    soupsieve                 2.0                      pypi_0    pypi
    sqlalchemy                1.3.15                   pypi_0    pypi
    sqlite                    3.30.0               h7b6447c_0  
    tblib                     1.6.0                      py_0    conda-forge
    tini                      0.18.0            h14c3975_1001    conda-forge
    tk                        8.6.8                hbc83047_0  
    toolz                     0.10.0                     py_0    conda-forge
    tornado                   6.0.3            py37h516909a_4    conda-forge
    tqdm                      4.36.1                     py_0  
    urllib3                   1.24.2                   py37_0  
    wheel                     0.33.6                   py37_0  
    xz                        5.2.4                h14c3975_4  
    yaml                      0.1.7                had09818_2  
    zict                      1.0.0                      py_0    conda-forge
    zlib                      1.2.11               h7b6447c_3  
    zstd                      1.4.4                h3b9ef0a_1    conda-forge
    
  9. mrocklin commented on Mar 20, 2020

    @mrocklin
    Member

    Yeah, I don't know what to tell you then. We don't use dill anywhere, so this must be coming from somewhere else

    (base) mrocklin@carbon-7:~/workspace/distributed$ git grep dill
    (base) mrocklin@carbon-7:~/workspace/distributed$ cd ../dask
    (base) mrocklin@carbon-7:~/workspace/dask$ git grep dill
    docs/source/changelog.rst:.. _`Eric Dill`: https://github.com/ericdill
    
  10. jrwalk commented on Mar 20, 2020

    @jrwalk
    Author

    Right. Looking at the stack trace, it does seem like it's deserializing with stock pickle - that is, the dask code isn't trying to run anything referencing dill. If I'm reading it right, it's getting an object passed to the dask cluster that itself contains a reference to dill, and it's complaining on deserialization of that?

  11. mrocklin commented on Mar 20, 2020

    @mrocklin
    Member
  12. jrwalk commented on Mar 20, 2020

    @jrwalk
    Author

    Alright, tracked it down I think. The failing task was being called from an Airflow DAG, and there's an imported (but unused in this case) dependency on dill for Airflow's python operators - that must be getting scooped up in the task serialization. Run in a clean REPL environment, the job passes. Curious that it wasn't complaining about other dependencies from the Airflow dependency, but I can poke that.

    In any case, this is clearly not a dask issue so I'll close. Thanks all!

  13. mrocklin commented on Mar 20, 2020

    @mrocklin
    Member
  14. mrocklin commented on Mar 20, 2020

    @mrocklin
    Member
  15. jrwalk commented on Mar 20, 2020

    @jrwalk
    Author

    Sure! development was generally quite smooth, this issue notwithstanding :)

    to be clear, we're not running airflow on a dask executor, and likely wouldn't move that direction (retaining queues for different resource requirements within the DAG is useful for us) though we're also working on moving that onto kubernetes. Instead the work was getting farmed out to the dask cluster from a normal Python operator within the DAG, with the data staged in S3. That lets us keep heterogeneity in Airflow, while farming out compute-heavy work to dask as needed.

    The usual story for why it's easy to develop with dask applied here - I initially wrote the dag out using the local process scheduler (rather than a local distributed client) but that was dead easy. Moving to the distributed client just required getting the data staging correct (s3fs was nice for that).

    As far as good vs. bad, most of the warts were more a consequence of the move to a distributed compute environment, rather than specific airflow interactions - I had some steps in the dask process using locally-defined functions, which worked with the local process scheduler but broke when distributed. Refactoring those to be easier for serialization wasn't particularly difficult though. For the dill issue, I'm thinking it'll likely work fine hitting that process from a virtualenv operator rather than one running in the Airflow environment (which I should do more anyhow >_> ), barring that now that we've tracked down the source it's not actually a big deal just pushing dill to the dask workers so the dependencies don't complain.

    Thanks for all the work on this!

  16. jrwalk commented on Mar 25, 2020

    @jrwalk
    Author

    Postscript re: the dill dependency getting scooped up when called from Airflow - it seems to specifically be when something references a datetime.datetime object. Even with an overhaul of the dask DAG (removing an intermediate dependency that was using datetime) that persists when called from an environment with dill installed.

    As to why that should be the case, I'm thoroughly stumped - but at least it's narrowed down to a specific issue!

  17. mrocklin commented on Mar 25, 2020

    @mrocklin
    Member
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions