Skip to content

Workers are extremely slow to start #193

Closed

Description

@lanougue

Hi everyone,
I play with a PBS cluster but each time I start a cluster, it takes more than 10 minutes to initiate.
Each node have 28 processors and I start 10 nodes = 280 workers (mono-thread)

My code is quite simple

cluster = PBSCluster()
cluster.start_workers(10)
client = Client(cluster)

Then, I use a home-made function to monitor how many workers are actually started

def wait_client_ready(client):
    """
    Wait for the client to be ready (all workers started)
    """
    import time, sys
    Nnodes = len(client.cluster.jobs)
    total_Nw = client.cluster.worker_processes*Nnodes
    Nw = 0.
    while(len(client._scheduler_identity.get('workers', {}))<total_Nw):
        p = len(client._scheduler_identity.get('workers', {}))/total_Nw
        time.sleep(2)
        if p>=Nw:
            Nw = int(p*10)/10
            print('{} % of the workers started'.format(int(p*100)))
            Nw+=0.1
    print('100 % of the workers started: {} workers'.format(total_Nw))

The first three lines are instantaneous and qstat on the frontal of my HPC shows that PBS gave me the 10 nodes I required (running status).
Then, the starting procedure of the workers is very slow: My monitoring function shows a relatively fast apparition of the first 50 % of the workers and then it takes a very long time to have the remaining 50 % (especially the last 10 %)

Here is my yaml config file:

  pbs:
    name: dask-worker

    # Dask worker options
    cores: 28       
    processes: 28   
    memory: 120GB
    interface: ib0
    death-timeout: 900 # should be large if many workers are launched
    local-directory: null

    # PBS resource manager options
    queue: mpi_1
    project: SKIM
    walltime: '48:00:00'
    extra: ""
    env-extra: []
    resource-spec: select=1:ncpus=28:mem=120GB
    job-extra: ['-m n']

Any idea of what could slow down the starting procedure of the workers ?

Activity

  1. guillaumeeb commented on Nov 12, 2018

    @guillaumeeb
    Member

    The first three lines are instantaneous and qstat on the frontal of my HPC shows that PBS gave me the 10 nodes I required (running status).

    Okay so this is quite important, it does not seem to be PBS related, that would have been my first guess!

    The only thing special about your config is that you're forking a lot of processes. I guess your tasks are GIL bounded?

    Several things I would recommand:

    • Go through output logs of your jobs, to identify if there is some error, timeout, or some kind of pattern that can be identified (maybe only some jobs are slowly starting, or maybe all the jobs have the same pattern).
    • Try launching the same amount of resources, but with less processes. Try launching only 5 jobs or less. Is there some kind of scaling limit?
    • Check if you are using recent versions of Dask or Distributed, that may have solved such an issue.

    One last point, you should use the cluster object in your waiting method. And directly use cluster.scheduler.workers.

  2. lanougue commented on Nov 13, 2018

    @lanougue
    Author

    The first three lines are instantaneous and qstat on the frontal of my HPC shows that PBS gave me the 10 nodes I required (running status).

    Okay so this is quite important, it does not seem to be PBS related, that would have been my first guess!

    The only thing special about your config is that you're forking a lot of processes. I guess your tasks are GIL bounded?

    I do not understand this point since I do not have sent any task at this point of the code. I am just waiting for the wokers to be all available.

    Several things I would recommand:

    • Go through output logs of your jobs, to identify if there is some error, timeout, or some kind of pattern that can be identified (maybe only some jobs are slowly starting, or maybe all the jobs have the same pattern).

    Looking at the log of the workers, I have nothing strange to report.

    • Try launching the same amount of resources, but with less processes. Try launching only 5 jobs or less. Is there some kind of scaling limit?
    • Check if you are using recent versions of Dask or Distributed, that may have solved such an issue.

    This is something I will look into now since my version is quite old now.

    One last point, you should use the cluster object in your waiting method. And directly use cluster.scheduler.workers.

    Ok, (If I remember well, this waiting function was not working anymore on the last version of dask/distributed. I will update it)
    Thanks

  3. lanougue commented on Nov 13, 2018

    @lanougue
    Author

    I updated my conda environement and I get the following result for the lastest version of Dask (0.20.1) / Distributed (1.24.0) with this minimalist code:

    from dask_jobqueue import PBSCluster
    cluster = PBSCluster()
    cluster.start_workers(1)
    

    Then I manually monitor the "cluster" variable to check the number of running workers as a function of time and here are the results:

    20 s : workers = 7/28
    1 min : workers = 10/28
    2 min : workers = 15/28
    3 min : workers = 19/28
    4 min : workers = 23/28
    5 min : workers = 27/28
    5 min, 27 s : workers = 28/28.
    

    It takes a few seconds to start the first worker and more than 25 seconds to start the last one !

    @mrocklin suggested here issus that it could be unrelated to dask/jobqueue and more linked to the system.
    @guillaumeeb = If possible, I would be curious if you can report the results you have with your cluster in such minimalist case.
    If yours is much faster, I will see what my system administrators can do.
    Thanks

  4. guillaumeeb commented on Nov 13, 2018

    @guillaumeeb
    Member

    I do not understand this point since I do not have sent any task at this point of the code. I am just waiting for the wokers to be all available.

    Why do you launch 28 processes on 28 cores, is it really needed? You could use python threads too if compatible with your workflow.

    Looking at the log of the workers, I have nothing strange to report.

    Could you share the logs? Do you only see things like :

    
    distributed.worker - INFO -       Start worker at:   tcp://10.x.y.z:41801
    distributed.worker - INFO -          Listening to:   tcp://10.x.y.z:41801
    distributed.worker - INFO -              nanny at:         10.x.y.z:46368
    distributed.worker - INFO -              bokeh at:         10.x.y.z:41571
    distributed.worker - INFO - Waiting to connect to:   tcp://10.x.y.z:45701
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -               Threads:                          1
    distributed.worker - INFO -                Memory:                    5.00 GB
    distributed.worker - INFO -       Local Directory: /tmp/pbs.8662870.admin01/worker-nh8zf5jy
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -         Registered to:   tcp://10.x.y.z:45701
    distributed.worker - INFO - -------------------------------------------------
    distributed.core - INFO - Starting established connection
    

    I've done the test on my system with

    def wait_cluster_ready(cluster, nworkers):
        """
        Wait for the client to be ready (all workers started)
        """
        import time, sys
        Nw = 0.
        while(len(cluster.scheduler.workers)<nworkers):
            p = len(cluster.scheduler.workers)/nworkers
            time.sleep(2)
            print('{} % of the workers started'.format(int(p*100)))
            if p>=Nw:
                Nw = int(p*10)/10
                Nw+=0.1
        print('100 % of the workers started: {} workers'.format(nworkers))

    and

    cluster = PBSCluster(processes=24, cores=24, memory="120GB", local_directory='$TMPDIR',
                         project='DaskTest', walltime='01:00:00', interface='ib0', log_directory='worker-logs')

    Once the PBS job is running, things are quite instantaneous, 10 seconds to get scheduled by PBS, and then all is up:

    0 % of the workers started
    0 % of the workers started
    0 % of the workers started
    0 % of the workers started
    100 % of the workers started: 24 workers
    

    Seems like you have trouble starting many processes...

    One thing that troubles me in your setup is

        local-directory: null
    

    This seems wrong. You should definitly use a local directory.

    I also remember @apatlpo was having some problem on your cluster (if I'm not mistaken), see #30.

  5. lanougue commented on Nov 14, 2018

    @lanougue
    Author

    I do not understand this point since I do not have sent any task at this point of the code. I am just waiting for the wokers to be all available.

    Why do you launch 28 processes on 28 cores, is it really needed? You could use python threads too if compatible with your workflow.

    I want to use as many processes as I can since my code is autoscaled as a function of the number of processes. For me, the highest the number of workers the faster is the code. I don't have any memory issue for the workers since they only use about 10% of their respective memory. I tried to use threads but it does not work well for me:

    • I need concurent access to netcdf4 file (very difficult with threads due to needed parallel-complient netcdf4 librairies) see this issue
    • subroutines lock the GIL

    I don't have these problems with independant processes.

    Looking at the log of the workers, I have nothing strange to report.

    Could you share the logs? Do you only see things like :

    
    distributed.worker - INFO -       Start worker at:   tcp://10.x.y.z:41801
    distributed.worker - INFO -          Listening to:   tcp://10.x.y.z:41801
    distributed.worker - INFO -              nanny at:         10.x.y.z:46368
    distributed.worker - INFO -              bokeh at:         10.x.y.z:41571
    distributed.worker - INFO - Waiting to connect to:   tcp://10.x.y.z:45701
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -               Threads:                          1
    distributed.worker - INFO -                Memory:                    5.00 GB
    distributed.worker - INFO -       Local Directory: /tmp/pbs.8662870.admin01/worker-nh8zf5jy
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -         Registered to:   tcp://10.x.y.z:45701
    distributed.worker - INFO - -------------------------------------------------
    distributed.core - INFO - Starting established connection
    

    Yes, I have this kind of logs:

    distributed.worker - INFO -       Start worker at:   tcp://10.148.0.110:40823
    distributed.worker - INFO -          Listening to:   tcp://10.148.0.110:40823
    distributed.worker - INFO -              nanny at:         10.148.0.110:44371
    distributed.worker - INFO -              bokeh at:         10.148.0.110:56534
    distributed.worker - INFO - Waiting to connect to:    tcp://10.148.1.35:42404
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -               Threads:                          1
    distributed.worker - INFO -                Memory:                    4.29 GB
    distributed.worker - INFO -       Local Directory: /home1/datahome/fnouguie/dask-worker-space/worker-c12b3hfl
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -       Start worker at:   tcp://10.148.0.110:38286
    distributed.worker - INFO -          Listening to:   tcp://10.148.0.110:38286
    distributed.worker - INFO -              nanny at:         10.148.0.110:46941
    distributed.worker - INFO -              bokeh at:         10.148.0.110:59440
    distributed.worker - INFO - Waiting to connect to:    tcp://10.148.1.35:42404
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -               Threads:                          1
    distributed.worker - INFO -                Memory:                    4.29 GB
    distributed.worker - INFO -       Local Directory: /home1/datahome/fnouguie/dask-worker-space/worker-uw7ylc0b
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -         Registered to:    tcp://10.148.1.35:42404
    distributed.worker - INFO -         Registered to:    tcp://10.148.1.35:42404
    

    The only permanent warning I have is

    /home1/datahome/fnouguie/miniconda3/envs/lops-array/lib/python3.6/site-packages/distributed/utils.py:134: RuntimeWarning: Couldn't detect a suitable IP address for reaching '8.8.8.8', defaulting to '127.0.0.1': [Errno 101] Network is unreachable
      % (host, default, e), RuntimeWarning)
    

    Could it be linked to this warning ?

    I've done the test on my system with

    def wait_cluster_ready(cluster, nworkers):
        """
        Wait for the client to be ready (all workers started)
        """
        import time, sys
        Nw = 0.
        while(len(cluster.scheduler.workers)<nworkers):
            p = len(cluster.scheduler.workers)/nworkers
            time.sleep(2)
            print('{} % of the workers started'.format(int(p*100)))
            if p>=Nw:
                Nw = int(p*10)/10
                Nw+=0.1
        print('100 % of the workers started: {} workers'.format(nworkers))

    and

    cluster = PBSCluster(processes=24, cores=24, memory="120GB", local_directory='$TMPDIR',
                         project='DaskTest', walltime='01:00:00', interface='ib0', log_directory='worker-logs')

    Once the PBS job is running, things are quite instantaneous, 10 seconds to get scheduled by PBS, and then all is up:

    0 % of the workers started
    0 % of the workers started
    0 % of the workers started
    0 % of the workers started
    100 % of the workers started: 24 workers
    

    Seems like you have trouble starting many processes...

    Yes, it seems so ! I will soon have acces to CNES cluster (huge project in collaboration) so I will be able to test this procedure on both clusters. We'll probably be in touch soon again.

    One thing that troubles me in your setup is

        local-directory: null
    

    This seems wrong. You should definitly use a local directory.

    I also remember @apatlpo was having some problem on your cluster (if I'm not mistaken), see #30.

    Ok, thanks for the advice. I will discuss about that with him

  6. added
    usage question
    on Nov 20, 2018
  7. guillaumeeb commented on Feb 4, 2019

    @guillaumeeb
    Member

    @lanougue any update on this? I still believe this is somehow linked to your cluster, where you able to test it elsewhere?

  8. lanougue commented on Feb 5, 2019

    @lanougue
    Author

    Hi @guillaumeeb ,
    I still have this issue (about 7 or 8 min to wake up 15 nodes with 28 workers on each = 420 workers).
    For the moment, while waiting for the workers, I am doing other useful calculations on the main stream.

    I was about to migrate to CNES cluster but I found a workaround with the other problem (memory issue while writing on disk) so, at that time, I'm still living with the problem of slow starting procedure of the workers.
    I definitely have to do some tests on CNES cluster. I will report back here when it will be done

  9. lanougue commented on Mar 12, 2019

    @lanougue
    Author

    Hi @guillaumeeb,
    I did a simple test with @apatlpo on CNES cluster and it worked like a charm (very fast initialization procedure). My problem seems to be linked to our cluster.
    I will try to change --local-directory to another file system as mentioned in #rapidsai/dask-cuda#11

  10. guillaumeeb commented on Mar 12, 2019

    @guillaumeeb
    Member

    Yep, always use --local-directory on an HPC Cluster and point that to a node local storage!

    Glad it worked fine on CNES cluster 😁

  11. mrocklin commented on Mar 12, 2019

    @mrocklin
    Member

    Note that there is also a local-directory entry in the configuration, if you want to apply it there for your system.

  12. lanougue commented on Mar 12, 2019

    @lanougue
    Author

    Ok, my mistake was to forgot to try harder the first suggestion of @guillaumeeb. In my config file jobqueue.yaml the local-directory field was set to "null" as noticed by @guillaumeeb. This seems to slow down the starting procedure of the workers but workers don't crash and the code can finally continu.
    I tried to set local-directory to some fixed location on one of the HPC disk but most of the workers die with errors (failed to start...).
    My salvation was to set local-directory to $TMPDIR and it is finally working fine now ! (it seems so obvious now...)
    Thanks to all for the help.

  13. manugarri commented on Jul 5, 2019

    @manugarri

    not sure if this belongs here but running on EMR my workers take 5-7 minutes to start, is that an expected time? For what im reading in this thread, it seems that adding local-directory to my conf wont work (since the emr only has temporary ebs storage I believe)

  14. mrocklin commented on Jul 5, 2019

    @mrocklin
    Member
  15. manugarri commented on Jul 5, 2019

    @manugarri

    my bad, will post it there.

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

    usage question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions