You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
distributed workers on kubernetes require dill #3606
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.
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:
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):
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 :)
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'
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'
It looks like something was serialized with `dill`. This isn't typical
with Dask usage today (we haven't used dill in years) so something is
likely up with your environment. A very old Dask worker on the system
would explain that, but apparently you've verified that that isn't the
case. Perhaps you're using Dask with some other library that is using
dill?
On Fri, Mar 20, 2020 at 11:36 AM John Walk ***@***.***> wrote:
and the kubernetes worker 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'
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3606 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACKZTBWIWYXEO3FG4TFKBTRIOZTXANCNFSM4LQPH6QA>
.
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?
Yeah perhaps. It could be that you're using a custom library that assumes
that dill is present for deserialization maybe? In your situation I would
try to provide a minimal reproducible case. My guess is that in creating
such an example you would likely find that your problem was isolated to a
particular library or workflow that you're doing outside of Dask.
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!
Also, I'm curious generally about how you've been finding the Airflow +
Dask experience. If you have a moment to write up the good and the bad I'd
love to read it.
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.
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!
You might consider raising an issue on Airflow to ask them to change to
cloudpickle. Most of the major distributed computing frameworks in Python
today have made that switch. Dill is great, but rarely deployed these days.
On Wed, Mar 25, 2020 at 7:03 AM John Walk ***@***.***> wrote:
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!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3606 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACKZTBZDHDO6RHR4I3NRDLRJIFLTANCNFSM4LQPH6QA>
.
Activity
lesteve commentedon Mar 20, 2020
dillwas 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
distributedyou are using on your workers and check that they are the same than the one on your scheduler and on your client:jrwalk commentedon Mar 20, 2020
Right, I'd seen that
dillwas removed a while back. Output of get_versions below (short version, does seem to be correctly seeingdistributed==2.11.0as 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" } } }jrwalk commentedon Mar 20, 2020
conda liston 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 :)lesteve commentedon Mar 20, 2020
Weird, maybe posting the full stack-trace you get with the
dillImportErrorcould be useful.jrwalk commentedon Mar 20, 2020
from the dask worker logs:
jrwalk commentedon Mar 20, 2020
and the kubernetes pod logs:
mrocklin commentedon Mar 20, 2020
jrwalk commentedon Mar 20, 2020
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 liston the k8s pod):mrocklin commentedon Mar 20, 2020
Yeah, I don't know what to tell you then. We don't use dill anywhere, so this must be coming from somewhere else
jrwalk commentedon Mar 20, 2020
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?
mrocklin commentedon Mar 20, 2020
jrwalk commentedon Mar 20, 2020
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
dillfor 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!
mrocklin commentedon Mar 20, 2020
mrocklin commentedon Mar 20, 2020
jrwalk commentedon Mar 20, 2020
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 (
s3fswas 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
dillissue, 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 pushingdillto the dask workers so the dependencies don't complain.Thanks for all the work on this!
jrwalk commentedon Mar 25, 2020
Postscript re: the
dilldependency getting scooped up when called from Airflow - it seems to specifically be when something references adatetime.datetimeobject. 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!
mrocklin commentedon Mar 25, 2020