Skip to content

LocalCluster not respecting dask distributed config #2456

Closed

Description

@bluecoconut

Running dask.config.set to update the worker memory targets does not seem to affect the worker limits in Cluster, and the config is not respected (despite being represented in the print)

import dask
from dask.datasets import timeseries
from distributed import LocalCluster, Client
dask.config.set({'distributed.worker.memory.target': False, 'distributed.worker.memory.spill': False})
print(dask.config.config['distributed']['worker']['memory'])
cluster = LocalCluster(n_workers=4, threads_per_worker=2, memory_limit='1G')
client = Client(cluster)
dfs = []
for i in range(60):
    dfs.append(client.persist(timeseries()))

I would have expected the code above to cause the workers to die and have some errors about memory, but I'm getting nothing. And subsequent calls, eg.

for x in dfs:
    print(x.size.compute())

Now take lots of time (data didn't fit in to memory, and is being loaded from disk).

How can I, in python, spin up a LocalCluster with no-spill settings?

Activity

  1. mrocklin commented on Jan 10, 2019

    @mrocklin
    Member

    You raise a good point. Some solutions:

    1. Today you can pass the appropriate keyword arguments with the worker_kwargs= parameter to LocalCluster. See the Worker docstring for arguments like memory_spill=
    2. It seems reasonable for us to pass the local configuration into the workers as we create them. This isn't implemented, but seems in scope.
  2. bluecoconut commented on Jan 10, 2019

    @bluecoconut
    Author

    For 1. I was not able to get it to work.

    I tried:

    cluster = LocalCluster(n_workers=4, threads_per_worker=2, memory_limit = '1G', memory_target_fraction=False, memory_spill_fraction=False)
    

    but I got an error (compatibility with Nanny?)

    ~/venv/lib/python3.7/site-packages/distributed/deploy/local.py in _start_worker(self, death_timeout, **kwargs)
        212         w = W(self.scheduler.address, loop=self.loop,
        213               death_timeout=death_timeout,
    --> 214               silence_logs=self.silence_logs, **kwargs)
        215         yield w._start()
        216 
    
    ~/venv/lib/python3.7/site-packages/distributed/nanny.py in __init__(self, scheduler_ip, scheduler_port, scheduler_file, worker_port, ncores, loop, local_dir, services, name, memory_limit, reconnect, validate, quiet, resources, silence_logs, death_timeout, preload, preload_argv, security, contact_address, listen_address, worker_class, env, **kwargs)
         98         super(Nanny, self).__init__(handlers, io_loop=self.loop,
         99                                     connection_args=self.connection_args,
    --> 100                                     **kwargs)
        101 
        102         if self.memory_limit:
    
    TypeError: __init__() got an unexpected keyword argument 'memory_target_fraction'
    
  3. mrocklin commented on Jan 11, 2019

    @mrocklin
    Member
  4. bluecoconut commented on Jan 11, 2019

    @bluecoconut
    Author

    Maybe I'm looking at the wrong thing or am being slow today, but I haven't been able to get this to work and I don't see what you mean about passing these into worker_kwargs keyword directly...

    According Docstrings and method signatures I found ( http://distributed.dask.org/en/latest/local-cluster.html and https://github.com/dask/distributed/blob/master/distributed/deploy/local.py ) it shows the worker_kwargs in the __init__ method as the named "catch all" for the magic **kwarg (specifically: **worker_kwargs). Wouldn't this imply that simply adding named-arguments to the declaration (as done in my example above), put the keys into the worker_kwargs dictionary?

    Additionally, I have no problem with the memory_limit kwarg (which is also passed along through worker_kwargs), it just seems to be the memory_target_fraction and memory_spill_fraction causing an issue.

  5. mrocklin commented on Jan 11, 2019

    @mrocklin
    Member
  6. bluecoconut commented on Jan 30, 2019

    @bluecoconut
    Author

    Any updates on possibly fixing this?

    I'm finding a lot of value in dynamically spinning up clusters via python (when using large machines), and having code-able configuration helps ensure behavior is predictable for each sub-cluster.

    The main use case for why I am spinning up multiple clusters at once on a single machine, is because I found that a single scheduler ends up being a bottle-neck, and since I have isolatable tasks on different sets of data, separating the work based on the data and tasks helps increase speed and parallelism without the bottle-neck.

  7. mrocklin commented on Jan 30, 2019

    @mrocklin
    Member

    No update from me. I don't plan to work on this personally near term (I'm slammed for the forseeable future). If anyone has time to take one of the approaches listed above that would be welcome.

  8. bchu commented on Apr 8, 2019

    @bchu
    Contributor

    @bluecoconut With #2596, the kwargs (e.g. memory_target_fraction, etc.) are now being passed through to the Worker.

  9. bluecoconut commented on Apr 8, 2019

    @bluecoconut
    Author

    Awesome! thank you~

  10. zyxue commented on Apr 21, 2019

    @zyxue

    Any update on this, please? I am using dask-1.2.0, still seeing memory getting out of control

    My code for creating a local cluster:

    from dask.distributed import Client, LocalCluster
    
    worker_kwargs = {
        'memory_limit': '2G',
        'memory_target_fraction': 0.6,
        'memory_spill_fraction': 0.7,
        'memory_pause_fraction': 0.8,
    #     'memory_terminate_fraction': 0.95,
    }
    
    cluster = LocalCluster(ip='0.0.0.0', n_workers=8, **worker_kwargs)
    client = Client(cluster)
    

    Then, there doesn't seem to be any control looking at the workers status at 8787

    distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
    distributed.nanny - WARNING - Worker process 7051 was killed by unknown signal
    distributed.nanny - WARNING - Restarting worker
    distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
    distributed.nanny - WARNING - Worker process 7460 was killed by unknown signal
    distributed.nanny - WARNING - Restarting worker
    distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
    distributed.nanny - WARNING - Worker process 7064 was killed by unknown signal
    distributed.nanny - WARNING - Restarting worker
    distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
    distributed.nanny - WARNING - Worker process 7484 was killed by unknown signal
    distributed.nanny - WARNING - Restarting worker
    distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
    distributed.nanny - WARNING - Worker process 7487 was killed by unknown signal
    distributed.nanny - WARNING - Restarting worker
    distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
    distributed.nanny - WARNING - Worker process 7058 was killed by unknown signal
    distributed.nanny - WARNING - Restarting worker
    distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
    distributed.nanny - WARNING - Worker process 7054 was killed by unknown signal
    distributed.nanny - WARNING - Restarting worker
    distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
    distributed.nanny - WARNING - Worker process 7062 was killed by unknown signal
    distributed.nanny - WARNING - Restarting worker
    distributed.nanny - WARNING - Worker exceeded 95% memory budget. Restarting
    distributed.nanny - WARNING - Worker process 7052 was killed by unknown signal
    distributed.nanny - WARNING - Restarting worker
    ---------------------------------------------------------------------------
    KilledWorker                              Traceback (most recent call last)
    <timed exec> in <module>
    ...
    KilledWorker: ("('from_pandas-apply-c649c11616ad42ef979ddfc109bcbcf9', 0)", 'tcp://10.168.0.2:40669')
    
  11. martindurant commented on Apr 21, 2019

    @martindurant
    Member

    @zyxue - please search for similar questions.
    We can't really guess at what your situation might be, but you should be aware that Dask has no control over how much memory might be allocated within a running task (such as intermediate copies), so keep that in mind when designing your workflow.

  12. mrocklin commented on Apr 27, 2019

    @mrocklin
    Member

    @zyxue I recommend raising a new issue with your situation

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