Skip to content

Dask with jobqueue not using multiple nodes #206

Closed

Description

@npaulson

I am trying to use Dask to do parallel processing on multiple nodes on supercomputing resources - yet the Dask-distributed map only takes advantage of one of the nodes. Note that I put this up on stackoverflow but didn't get attention so now I'm giving here a go.

Here is a test script I am using to set up the client and perform a simple operation:

import time
from distributed import Client
from dask_jobqueue import SLURMCluster
from socket import gethostname


def slow_increment(x):
    time.sleep(10)
    return [x + 1, gethostname(), time.time()]


cluster = SLURMCluster(
    queue='somequeue',
    cores=2,
    memory='128GB',
    project='someproject',
    walltime='00:05:00',
    job_extra=['-o myjob.%j.%N.out',
               '-e myjob.%j.%N.error'],
    env_extra=['export I_MPI_FABRICS=dapl',
               'source activate dask-jobqueue'])

cluster.scale(2)

client = Client(cluster)

A = client.map(slow_increment, range(8))
B = client.gather(A)

print(client)

for res in B:
    print(res)

client.close()

And here is the output:

<Client: scheduler='tcp://someip' processes=2 cores=4>
[1, 'bdw-0478', 1540477582.6744401]
[2, 'bdw-0478', 1540477582.67487]
[3, 'bdw-0478', 1540477592.68666]
[4, 'bdw-0478', 1540477592.6879778]
[5, 'bdw-0478', 1540477602.6986163]
[6, 'bdw-0478', 1540477602.6997452]
[7, 'bdw-0478', 1540477612.7100565]
[8, 'bdw-0478', 1540477612.711296]

While printing out the client info indicates that Dask has the correct number of nodes (processes) and tasks per node (cores), the socket.gethostname() output and time-stamps indicate that the second node isn't used. I do know that dask-jobqueue successfully requested two nodes, and that both jobs complete at the same time. I tried using different MPI Fabrics for inter- and intra-node communication (e.g. tcp, shm:tcp, shm:ofa, ofa, ofi, dapl) but this did not change the result. I also tried removing the "export I_MPI_FABRICS" command and using the "interface" option, but this caused the code to hang.

Thanks in advance for any assistance.

-Noah

Activity

  1. guillaumeeb commented on Dec 4, 2018

    @guillaumeeb
    Member

    Note that I put this up on stackoverflow but didn't get attention so now I'm giving here a go.

    Sorry we miss this question, I do not personnaly watch Stack Overflow, but I should. You issue may also belong to dask-jobqueue, but that's not really important for the time being.

    After a quick glance at your code, I cannot see anything wrong. So we will need to find a way to debug what's going on.

    I tried using different MPI Fabrics for inter- and intra-node communication (e.g. tcp, shm:tcp, shm:ofa, ofa, ofi, dapl) but this did not change the result

    Dask does not use MPI for communication, only plain TCP, so either ethernet interfaces, or IP over IB. Did you try without any fabrics, and without interface option ?

    Some other thoughts:

  2. jhamman commented on Dec 4, 2018

    @jhamman
    Member

    I suggest we move this issue to dask-jobqueue. One of the dask devs may be able to actually move this issue there (new GH feature) or @npaulson can just cross post.

  3. transferred this issue fromdask/distributedon Dec 4, 2018
  4. mrocklin commented on Dec 4, 2018

    @mrocklin
    Member

    Transferred. Also gave all org members with the ability to delete issues, which I hope implies the ability to move them.

  5. npaulson commented on Dec 4, 2018

    @npaulson
    Author

    Thank you for taking an interest in my issue!

    @guillaumeeb, below I'm including short descriptions of my investigations into your various debugging suggestions and after the full code, it's output and stderror.

    Dask does not use MPI for communication, only plain TCP, so either ethernet interfaces, or IP over IB. Did you try without any fabrics, and without interface option ?

    When I don't explicitly define the fabrics and don't include an interface option the code runs similarly as before.

    You should print(client) before the map just to be sure, but I imagine the cluster was formed before the end of the gather, especially if jobs ended at the same time.

    To check this I printed the client before the gather operation and it appears to have formed properly.

    Did you try opening the Dask Dashboard to watch the computation?

    I haven't yet figured out how do to this, though I'm looking into it next.

    Do you have something interesting in Slurm stdout or stderr?

    The stdout is empty but there are details in stderr.

    You can also look at http://jobqueue.dask.org/en/latest/debug.html to see if there is something relevant. Thinking about debug mode for instance.

    I have enabled debugging mode and included the output below. Some of the other suggestions seem to deal with getting the jobs themselves through SLURM, though I don't seem to be having a problem in that regard.

    Here is the updated version of my code:

    import time
    import logging
    from distributed import Client
    from dask_jobqueue import SLURMCluster
    from socket import gethostname
    
    
    logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
    
    
    def slow_increment(x):
        time.sleep(10)
        return [x + 1, gethostname(), time.time()]
    
    
    cluster = SLURMCluster(
        queue='bdwall',
        cores=2,
        memory='128GB',
        project='STARTUP-NPAULSON',
        walltime='00:05:00',
        job_extra=['-o myjob.%j.%N.out',
                   '-e myjob.%j.%N.error'])
    
    cluster.scale(2)
    
    client = Client(cluster)
    
    A = client.map(slow_increment, range(8))
    
    time.sleep(15)
    print('\n::: start user output :::')
    print(client)
    print('::: end user output :::\n')
    
    B = client.gather(A)
    
    print('\n::: start user output :::')
    print(client)
    print('::: end user output :::\n')
    
    for res in B:
        print(res)
    
    client.close()

    Here is the output of my code with logging enabled:

    DEBUG:Using selector: EpollSelector
    DEBUG:Using selector: EpollSelector
    DEBUG:Using selector: EpollSelector
    DEBUG:Job script:
     #!/bin/bash
    
    #!/usr/bin/env bash
    #SBATCH -J dask-worker
    #SBATCH -p bdwall
    #SBATCH -A STARTUP-NPAULSON
    #SBATCH -n 1
    #SBATCH --cpus-per-task=2
    #SBATCH --mem=120G
    #SBATCH -t 00:05:00
    #SBATCH -o myjob.%j.%N.out
    #SBATCH -e myjob.%j.%N.error
    JOB_ID=${SLURM_JOB_ID%;*}
    
    
    
    /home/npaulson/miniconda/envs/dask-jobqueue/bin/python -m distributed.cli.dask_worker tcp://140.221.70.5:38499 --nthreads 2 --memory-limit 128.00GB --name dask-worker--${JOB_ID}-- --death-timeout 60
    
    DEBUG:Found 0 active/pending workers.
    DEBUG:Scaling up to 2 workers.
    DEBUG:Using selector: EpollSelector
    DEBUG:Found 0 active/pending workers.
    DEBUG:starting 2 workers
    DEBUG:Using selector: EpollSelector
    DEBUG:writing job script:
    #!/bin/bash
    
    #!/usr/bin/env bash
    #SBATCH -J dask-worker
    #SBATCH -p bdwall
    #SBATCH -A STARTUP-NPAULSON
    #SBATCH -n 1
    #SBATCH --cpus-per-task=2
    #SBATCH --mem=120G
    #SBATCH -t 00:05:00
    #SBATCH -o myjob.%j.%N.out
    #SBATCH -e myjob.%j.%N.error
    JOB_ID=${SLURM_JOB_ID%;*}
    
    
    
    /home/npaulson/miniconda/envs/dask-jobqueue/bin/python -m distributed.cli.dask_worker tcp://140.221.70.5:38499 --nthreads 2 --memory-limit 128.00GB --name dask-worker--${JOB_ID}-- --death-timeout 60
    
    DEBUG:Executing the following command to command line
    sbatch --parsable /tmp/tmpl5nkitoz.sh
    DEBUG:started job: 802327
    DEBUG:writing job script:
    #!/bin/bash
    
    #!/usr/bin/env bash
    #SBATCH -J dask-worker
    #SBATCH -p bdwall
    #SBATCH -A STARTUP-NPAULSON
    #SBATCH -n 1
    #SBATCH --cpus-per-task=2
    #SBATCH --mem=120G
    #SBATCH -t 00:05:00
    #SBATCH -o myjob.%j.%N.out
    #SBATCH -e myjob.%j.%N.error
    JOB_ID=${SLURM_JOB_ID%;*}
    
    
    
    /home/npaulson/miniconda/envs/dask-jobqueue/bin/python -m distributed.cli.dask_worker tcp://140.221.70.5:38499 --nthreads 2 --memory-limit 128.00GB --name dask-worker--${JOB_ID}-- --death-timeout 60
    
    DEBUG:Executing the following command to command line
    sbatch --parsable /tmp/tmp_8knxogn.sh
    DEBUG:started job: 802328
    DEBUG:adding worker tcp://10.70.129.58:32853
    DEBUG:job id for new worker: 802328
    DEBUG:802328 is a new job or restarting worker
    DEBUG:802328 is a new job, adding to running_jobs
    DEBUG:adding worker tcp://10.70.130.174:33998
    DEBUG:job id for new worker: 802327
    DEBUG:802327 is a new job or restarting worker
    DEBUG:802327 is a new job, adding to running_jobs
    
    ::: start user output :::
    <Client: scheduler='tcp://140.221.70.5:38499' processes=2 cores=4>
    ::: end user output :::
    
    
    ::: start user output :::
    <Client: scheduler='tcp://140.221.70.5:38499' processes=2 cores=4>
    ::: end user output :::
    
    [1, 'bdw-0285', 1543964816.1772363]
    [2, 'bdw-0285', 1543964816.1834495]
    [3, 'bdw-0285', 1543964826.187123]
    [4, 'bdw-0285', 1543964826.1882021]
    [5, 'bdw-0285', 1543964836.198275]
    [6, 'bdw-0285', 1543964836.199521]
    [7, 'bdw-0285', 1543964846.209588]
    [8, 'bdw-0285', 1543964846.210915]
    

    Here is the stderror for node 00048:

    Warning: Your terminal does not set locales.
    
    If you use unicode text inputs for command line options then this may cause
    undesired behavior.  This is rare.
    
    If you don't use unicode characters in command line options then you can safely
    ignore this message.  This is the common case.
    
    You can support unicode inputs by specifying encoding environment variables,
    though exact solutions may depend on your system:
    
        $ export LC_ALL=C.UTF-8
        $ export LANG=C.UTF-8
    
    For more information see: http://click.pocoo.org/5/python3/
    
    distributed.nanny - INFO -         Start Nanny at: 'tcp://10.70.130.174:40144'
    distributed.diskutils - INFO - Found stale lock file and directory '/blues/gpfs/home/npaulson/2018_10_24_dask/dask-worker-space/worker-bqgulcd7', purging
    distributed.worker - INFO -       Start worker at:  tcp://10.70.130.174:33998
    distributed.worker - INFO -          Listening to:  tcp://10.70.130.174:33998
    distributed.worker - INFO -              nanny at:        10.70.130.174:40144
    distributed.worker - INFO -              bokeh at:        10.70.130.174:36591
    distributed.worker - INFO - Waiting to connect to:   tcp://140.221.70.5:38499
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -               Threads:                          2
    distributed.worker - INFO -                Memory:                  128.00 GB
    distributed.worker - INFO -       Local Directory: /blues/gpfs/home/npaulson/2018_10_24_dask/dask-worker-space/worker-si3_68ly
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -         Registered to:   tcp://140.221.70.5:38499
    distributed.worker - INFO - -------------------------------------------------
    distributed.core - INFO - Starting established connection
    distributed.worker - INFO - Stopping worker at tcp://10.70.130.174:33998
    distributed.worker - INFO - Connection to scheduler broken.  Reconnecting...
    distributed.worker - INFO - -------------------------------------------------
    distributed.nanny - INFO - Closing Nanny at 'tcp://10.70.130.174:40144'
    distributed.dask_worker - INFO - End worker
    

    Here is the stderror for node 00285:

    Warning: Your terminal does not set locales.
    
    If you use unicode text inputs for command line options then this may cause
    undesired behavior.  This is rare.
    
    If you don't use unicode characters in command line options then you can safely
    ignore this message.  This is the common case.
    
    You can support unicode inputs by specifying encoding environment variables,
    though exact solutions may depend on your system:
    
        $ export LC_ALL=C.UTF-8
        $ export LANG=C.UTF-8
    
    For more information see: http://click.pocoo.org/5/python3/
    
    distributed.nanny - INFO -         Start Nanny at: 'tcp://10.70.129.58:43857'
    distributed.worker - INFO -       Start worker at:   tcp://10.70.129.58:32853
    distributed.worker - INFO -          Listening to:   tcp://10.70.129.58:32853
    distributed.worker - INFO -              nanny at:         10.70.129.58:43857
    distributed.worker - INFO -              bokeh at:         10.70.129.58:43568
    distributed.worker - INFO - Waiting to connect to:   tcp://140.221.70.5:38499
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -               Threads:                          2
    distributed.worker - INFO -                Memory:                  128.00 GB
    distributed.worker - INFO -       Local Directory: /blues/gpfs/home/npaulson/2018_10_24_dask/dask-worker-space/worker-bqgulcd7
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -         Registered to:   tcp://140.221.70.5:38499
    distributed.worker - INFO - -------------------------------------------------
    distributed.core - INFO - Starting established connection
    distributed.worker - INFO - Stopping worker at tcp://10.70.129.58:32853
    distributed.diskutils - ERROR - Failed to remove '/blues/gpfs/home/npaulson/2018_10_24_dask/dask-worker-space/worker-bqgulcd7' (failed in <built-in function lstat>): [Errno 2] No such file or directory: '/blues/gpfs/home/npaulson/2018_10_24_dask/dask-worker-space/worker-bqgulcd7'
    distributed.worker - INFO - Connection to scheduler broken.  Reconnecting...
    distributed.worker - INFO - -------------------------------------------------
    distributed.nanny - INFO - Closing Nanny at 'tcp://10.70.129.58:43857'
    distributed.dask_worker - INFO - End worker
    
  6. guillaumeeb commented on Dec 6, 2018

    @guillaumeeb
    Member

    I don't think this would change the behavior you see, but you should set local-directory kwarg to /tmp, /scratch or any other space local to you compute nodes.

    Still no idea here, you should try to use the dashboard to se if you see some strange things.

  7. npaulson commented on Dec 11, 2018

    @npaulson
    Author

    I've tried accessing the dashboard, which sometimes populates with the workers but other times does not. When it does populate with the workers, it only shows two - which I assume are the workers associated with the single node that reports back.

  8. guillaumeeb commented on Dec 11, 2018

    @guillaumeeb
    Member

    If it shoes two workers, then it's showing both nodes you're using. You've got one worker process per node with your config. It is really strange that tasks are only executed on one node. You should be able to see worker activity with the dashboard, and see where your tasks are executed.

  9. goraj commented on Dec 12, 2018

    @goraj

    I believe I have the same issue using SGE/UGE, I can start multiple job scripts but every job runs on the same node/PID

    from dask.distributed import Client
    from dask_jobqueue import SGECluster
    import os
    import socket
    
    def do_process():
        hostname = socket.gethostname()
        pid = os.getpid()
        return hostname, pid
    
    
    if __name__ == '__main__':
        memory = '10'
        n_workers = 10
        use_cluster = True
        if use_cluster:
            cluster = SGECluster(#queue='default.q',
                                processes=1, # number of python processes per job
                                cores=24, # cores per job
                                memory='10GB',
                                walltime='1500',
                                resource_spec=f'm_mem_free=10G')
            cluster.scale(n_workers)
            print(cluster.job_script())
        with Client(cluster) as client:
            pool = []
            for x in range(n_workers):
                pool.append(client.submit(do_process, pure=False, ))
    
            result = client.gather(pool)
            print(f'result: {result}')
            cluster.close()
            import IPython
            IPython.embed()
    

    Result:

    result: [('node2114', 172018), ('node2114', 172018), ('node2114', 172018), ('node2114', 172018), ('node2114', 172018), ('node2114', 172018), ('node2114', 172018), ('node2114', 172018), ('node2114', 172018), ('node2114', 172018)]
    

    qstat output:

    Every 0.1s: qstat                                                                                                                    Tue Dec 11 17:15:16 2018
    
    job-ID     prior   name       user         state submit/start at     queue                          jclass                         slots ja-task-ID
    ------------------------------------------------------------------------------------------------------------------------------------------------
      17250741 0.50203 dask-worke username      dr    12/11/2018 17:15:12 [email protected]                                    1
      17250743 0.50089 dask-worke username      dr    12/11/2018 17:15:12 [email protected]                                    1
      17250744 0.50051 dask-worke username      dr    12/11/2018 17:15:12 [email protected]                                    1
      17250745 0.50032 dask-worke username      dr    12/11/2018 17:15:12 [email protected]                                    1
      17250746 0.50021 dask-worke username      dr    12/11/2018 17:15:12 [email protected]                                    1
      17250747 0.50013 dask-worke username      dr    12/11/2018 17:15:12 [email protected]                                    1
      17250748 0.50008 dask-worke username      dr    12/11/2018 17:15:12 [email protected]                                    1
      17250749 0.50004 dask-worke username      dr    12/11/2018 17:15:12 [email protected]                                    1
      17250750 0.50001 dask-worke username      dr    12/11/2018 17:15:12 [email protected]                                    1
      17250751 0.49998 dask-worke username      dr    12/11/2018 17:15:12 [email protected]                                    1
    
  10. mrocklin commented on Dec 12, 2018

    @mrocklin
    Member

    My guess is that once the first worker arrives it gets all of the work, and that this work finishes well before the second worker arrives a subsecond later. Maybe try waiting until all of the workers have arrived?

  11. goraj commented on Dec 12, 2018

    @goraj

    @mrocklin Yes that would make sense. However the workers all spawn and run nearly instantly and at the same time.
    Still when submitting long running jobs they still all get submitted to the same node and run on the same PID.

    Sleeping between scale and submit seems to solves this. I assume my idea of the scheduler is wrong. The workers all spawn and run well before the first job is processed. And still all of them are pushed to that node without the sleep between scale and submit.

    For future reference: The following script is able to run all jobs on different nodes, unfortunately it requires all workers to run before we can submit:

    # -*- coding: utf-8 -*-
    import os
    import pandas as pd
    from dask.distributed import Client
    from dask_jobqueue import SGECluster
    from distributed.deploy.local import LocalCluster
    import time
    import socket
    from datetime import datetime
    
    def do_process():
        hostname = socket.gethostname()
        pid = os.getpid()
        return hostname, pid, str(datetime.now())
    
    
    if __name__ == '__main__':
        memory = '10'
        n_workers = 2
        use_cluster = True
        if use_cluster:
            cluster = SGECluster(queue='default.q',
                                processes=1,  # number of python processes per job
                                cores=24,  # cores per job
                                memory='10GB',
                                walltime='1500',
                                resource_spec='m_mem_free=10G')
            cluster.scale(n_workers)
        with Client(cluster) as client:
            pool = []
    
            while use_cluster and (client.status == 'running') and (len(client.scheduler_info()['workers']) < n_workers):
                time.sleep(1.0)
    
            print('start submitting jobs')
            for x in range(n_workers):
                print(x)
                pool.append(client.submit(do_process, pure=False, ))
    
            print('gathering results')
            result = client.gather(pool)
            print(f'result: {result}')
            cluster.close()
            import IPython
            IPython.embed()
    
    
  12. npaulson commented on Dec 12, 2018

    @npaulson
    Author

    I modified my code to include @mrocklin 's suggestion but still only one of the nodes is doing any work. I verified this on the dashboard by having my task instantiate a large numpy array. On the dashboard I see both nodes being initialized, but processing is only done on one of the nodes.

    @guillaumeeb , I also simplified the script so that only one process is started per node.

    The updated script is included below:

    import time
    import logging
    import numpy as np
    from distributed import Client
    from dask_jobqueue import SLURMCluster
    from socket import gethostname
    
    
    logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
    
    
    def slow_increment(x):
        m = np.random.random((100000, 10000))
        time.sleep(10)
        return [x + 1, gethostname(), time.time()]
    
    
    cluster = SLURMCluster(
        queue='bdwall',
        cores=1,
        memory='128GB',
        project='BAYES_THERMO',
        walltime='00:05:00',
        job_extra=['-o myjob.%j.%N.out',
                   '-e myjob.%j.%N.error'])
    
    cluster.scale(2)
    
    client = Client(cluster)
    
    A = client.map(slow_increment, range(8))
    
    time.sleep(10)
    
    B = client.gather(A)
    
    print('\n::: start user output :::')
    print(client)
    print('::: end user output :::\n')
    
    for res in B:
        print(res)
    
    client.close()
  13. mrocklin commented on Dec 12, 2018

    @mrocklin
    Member
  14. guillaumeeb commented on Dec 12, 2018

    @guillaumeeb
    Member

    There are two different situations here.

    @goraj why do you want your tasks to be submitted to different workers? I think @mrocklin comments are for you. There are other solutions if you want only one task per node than using sleep and waiting for all the cluster to be up.

    @npaulson I still don't see where the problem can be. I will try to execute your code, but I don't expect to run on the same issue. There should be scheduling error if no tasks can be sent to one of your worker. @mrocklin is there a way to see this kind of errors?

  15. goraj commented on Dec 13, 2018

    @goraj

    @guillaumeeb so I have hundreds of very long running jobs that are not thread-safe.
    I also want each to run on its own cluster node and use all available cpus there.

    Unfortunately I cannot figure out how to get each job to one cluster node using dask-jobqueue without using the wait like so:

    while use_cluster and (client.status == 'running') and (len(client.scheduler_info()['workers']) < n_workers):
                time.sleep(1.0)
    

    It is likely that my mental model is wrong and I would highly appreciate any tips or changes I should consider. Thank you all for the help and sorry for hijacking this issue, I thought I had the same problem as @npaulson.

  16. 30 remaining items

  17. mrocklin commented on Jun 22, 2020

    @mrocklin
    Member
  18. lesteve commented on Jun 22, 2020

    @lesteve
    Member

    (CNN inference)

    You may be interested to look at: https://examples.dask.org/machine-learning/torch-prediction.html. It is with a LocalCluster but easy to translate to a SLURMCluster.

    I know how many SLURM jobs (dask workers) I can request without having to wait.

    I would say in a typical HPC cluster this is rather unusual but I may be biased by the HPC clusters I am familiar with ... generally you have no idea how long you have to wait for your one job to start (it can depend on how people are using the cluster, on your past usage and probably on other factors) and even less for many jobs to start.

    reschedule jobs from busy workers to idle workers.

    Work stealing does that in principle automatically for you. If all your jobs do start running (i.e. squeue shows them running) as you say, this does point towards work stealing not kicking in your use case, hard to tell why but maybe the doc can help.

  19. ocaisa commented on Jun 22, 2020

    @ocaisa
    Member

    I also think dask-mpi is what you want for your use case, the workers will start instantly and you can tweak your SLURM job requirements to give you the distribution you want (1 MPI task per node would mean one worker per node, no need for a map step)

  20. fabiansvara commented on Jun 22, 2020

    @fabiansvara

    Work stealing does that in principle automatically for you. If all your jobs do start running (i.e. squeue shows them running) as you say, this does point towards work stealing not kicking in your use case, hard to tell why but maybe the doc can help.

    If that worked it would make the whole issue moot. According to the work stealing docs:

    If a task has been specifically restricted to run on particular workers (such as is the case when special hardware is required) then we do not steal.

    ... depending on how exactly I interpret this sentence, it might explain what's going on. I instantiate the SLURMCluster with extra=['--resources GPU=1'] and call map with resources={'GPU': 1}. This is because the GPU nodes also have a lot of CPUs, so they could also be used for running multiple CPU-bound jobs in other cases.

    If I interpret the sentence from the doc to mean "jobs where resources were specified will not be stolen", then that's the problem. Here in my case, it would be perfectly fine for other workers that have the same resource available to steal the jobs.

    Edit: It also explains the trouble that the person in #304 was having.

  21. lesteve commented on Jun 22, 2020

    @lesteve
    Member

    If I interpret the sentence from the doc to mean "jobs where resources were specified will not be stolen", then that's the problem.

    This was indeed a limitation but a PR supposed to fix this (dask/distributed#3069) has been merged. It seems like this is in 2.12 so maybe check that you distributed version is recent enough.

    If that still does not work for you this could be a problem with the PR or work stealing that does not kick in for some reason in your particular case ... hard to tell ...

    And of course the distributed doc may also need to be fixed as well ...

  22. fabiansvara commented on Jun 22, 2020

    @fabiansvara

    Hm, I have 2.18.0. Anything I can do to narrow down what's going on?

  23. lesteve commented on Jun 22, 2020

    @lesteve
    Member

    Yeah that was my guess that your version was recent enough.

    could you first post a snippet to show how you are creating your cluster and using it. In an ideal world a stand-alone snippet reproducing the problem would be great.

    Here are a list of suggestions at this point:

    • can you make sure that without resource work-stealing does happen
    • do you need to actually use resource? For embarassingly parallel use cases, I would think that this is not a requirement but maybe I am missing something.
    • how to debug work stealing in general I don't know there may be some debugging options or a dashboard that can help. Searching in the distributed issue tracker or asking there would be a good idea.
  24. fabiansvara commented on Jun 23, 2020

    @fabiansvara

    Finally found some time to experiment with this.

    Here's my complete testing code:

    from dask_jobqueue import SLURMCluster
    from dask.distributed import Client
    import time
    import itertools as it
    
    def _worker(worker_id):
        print(f'{worker_id=} starting.')
        time.sleep(10)
        print(f'{worker_id=} done.')
    
    def dask_map(wait=True, with_resource=True, cores=20, workers=5):
        if with_resource:
            extra = ['--resources GPU=1']
            resources = {'GPU': 1}
        else:
            extra = []
            resources = {}
    
        cluster = SLURMCluster(
            cores=cores,
            processes=1,
            memory='188GB',
            walltime='24:00:00',
            queue='my.queue',
            shebang='#!/bin/bash -l',
            local_directory='/my/local/dir/',
            extra=extra,
            job_extra=['--gres=gpu:1', ],
            env_extra=[
                'module load cuda',
                'module load anaconda',
                'conda init bash',
                'conda activate /my/conda/env',])
        cluster.scale(workers)
        client = Client(cluster)
    
        if wait:
            client.wait_for_workers(workers)
        f = client.map(_worker, list(range(workers)), resources=resources)
        [xx.result() for xx in f]
    
        cluster.scale(n=0, jobs=0)
        cluster.close()
    
    if __name__ == '__main__':
        for wait, with_resource, cores in it.product([False, True], [True, False], [20, 1]):
            t0 = time.time()
            dask_map(wait=wait, with_resource=with_resource, cores=cores)
            total_t = time.time() - t0
            print(f'{wait=}, {with_resource=}, {cores=} took {total_t:.2f} s')

    This prints the following:

    wait=False, with_resource=True, cores=20 took 55.11 s
    wait=False, with_resource=True, cores=1 took 14.09 s
    wait=False, with_resource=False, cores=20 took 13.84 s
    wait=False, with_resource=False, cores=1 took 14.29 s
    wait=True, with_resource=True, cores=20 took 15.28 s
    wait=True, with_resource=True, cores=1 took 14.45 s
    wait=True, with_resource=False, cores=20 took 14.58 s
    wait=True, with_resource=False, cores=1 took 14.43 s
    

    (the individual lines are separated by

    distributed.client - ERROR - Failed to reconnect to scheduler after 10.00 seconds, closing client
    _GatheringFuture exception was never retrieved
    future: <_GatheringFuture finished exception=CancelledError()>
    asyncio.exceptions.CancelledError
    

    ... I removed that from the output above for clarity. This seems to be caused be the creation / closing of the cluster in the loop; it doesn't influence the results, which are identical when this is not run in a loop.)

    Anyway, as you can see, the issue only occurs in the wait=False, with_resource=True, cores=20 case, where the jobs run sequentially. The workers are all there, but only one of them is doing anything. This is what it looks like in the dashboard:

    dask_dashboard

  25. lesteve commented on Jun 24, 2020

    @lesteve
    Member

    Thanks a lot for doing this! So it looks like work-stealing with resources does happen when cores=1, which is good to confirm.

    The case where it does not work is when you have cores=20. I am not an expert on the work stealing logic, but I can only guess that work-stealing does not kick in because the scheduler sees 20 slots on the first node (one slot for each core) with 5 tasks to execute so the worker doesn't seem busy and work stealing does not seem worth it. It could be interesting to confirm this hypothesis by submitting many more short tasks and see whether work stealing happens. It could also be worth getting some inputs by @mrocklin to make sure my hypothesis seems reasonable to him ...

    Maybe this is something that can be improved in distributed, not sure. I guess it should be possible to create a reproducer with distributed.SSHCluster so that more people are likely to look at it.

  26. fabiansvara commented on Jun 25, 2020

    @fabiansvara

    I looked into the documentation but couldn't find out how to create an SSHCluster with resources, not sure I can be of any help there. Should I create an issue specifically about work stealing on the distributed tracker?

  27. appassionate commented on Nov 25, 2022

    @appassionate

    @fabiansvara @lesteve
    Hi, sorry for discussing this in this old issue, any news in this using of job-queue?
    In my case, i want to map more "MPI" jobs in client by cluster.scale.

    Dask scheduler seems to manage task by the total threads in the workers. If cores to be 32(my hpc cores per node) ,there will be 32 threads in a worker, and any client.submit method will be executed as one thread ( i guess). So It is tricky to set cores to be 1, let the scheduler know there only one thread in a work, but actually, task in this worker will launch a MPI job, which might be "work-stealing " you are talking about? thanks.

    Here is my cluster config.

            cluster = SLURMCluster(
                n_workers=1,
                processes=1,
                queue=queue,
                interface="ib0",
                walltime=max_run_time,
                cores=1, #trick for using this slurm cluster
                memory="100 GB",
                job_extra_directives=[f'--ntasks-per-node={core_per_node}'],
                #job_cpu=1,
                )
            print(cluster.job_script())

    Is there way that dask scheduler not manage submit task by threads but the worker_num?
    Any suggestions will be helpful! thank u! :)

  28. ocaisa commented on Nov 25, 2022

    @ocaisa
    Member

    @appassionate We created a library that does what you are asking for but I admit it requires quite a bit of configuration since you need to tell it about the system and how you launch MPI jobs there. The library is at https://github.com/E-CAM/jobqueue_features and there's a tutorial at https://github.com/E-CAM/jobqueue_features_workshop_materials (and you can find a recording of the tutorial at https://www.youtube.com/watch?v=FpMua8iJeTk&ab_channel=E-CAM).

    I haven't touched it in a few months, need to check if our CI is still passing. That package is working with the latest version of jobqueue (0.8.1)

  29. appassionate commented on Nov 27, 2022

    @appassionate

    @appassionate We created a library that does what you are asking for but I admit it requires quite a bit of configuration since you need to tell it about the system and how you launch MPI jobs there.

    @ocaisa waow cool! Many thanks!!

  30. guillaumeeb commented on Nov 29, 2022

    @guillaumeeb
    Member

    @appassionate, with your comment, it is not really clear to me what you're trying to achieve.

    Anyway, if @ocaisa answer suits you, this is perfect, if not, I encourage you to open a new issue and try to make your issue a bit clearer.

  31. appassionate commented on Dec 1, 2022

    @appassionate

    @appassionate, with your comment, it is not really clear to me what you're trying to achieve.

    Anyway, if @ocaisa answer suits you, this is perfect, if not, I encourage you to open a new issue and try to make your issue a bit clearer.

    Thanks for your suggestion! jobqueue_features have customized the "SlurmCluster" for some MPI using, i believe there will be some using in such as "more nodes" in slurm which is suitable for me.

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