Skip to content

SLURM cluster only schedules one task on 20 workers (19 idle) #230

Closed

Description

@wkerzendorf

The general idea is to use dask to schedule an embarrassingly parallel problem where each task requires 8 cores (is threaded via OpenMP). That means that one worker should only take one task.

This started here #181 - I'm now running my cluster like this

cluster = SLURMCluster(walltime='01:00:00', memory='7 GB', 
                       job_extra=['--nodes=1', '--ntasks-per-node=1', '--cpus-per-task=8'], cores=8, extra=['--resources processes=1'])
client = Client(cluster)

resulting in

#!/bin/bash

#!/usr/bin/env bash
#SBATCH -J dask-worker
#SBATCH -n 1
#SBATCH --cpus-per-task=8
#SBATCH --mem=7G
#SBATCH -t 01:00:00
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=8
JOB_ID=${SLURM_JOB_ID%;*}



/home/wek224/.conda/envs/tardis3/bin/python -m distributed.cli.dask_worker tcp://172.16.2.152:45751 --nthreads 8 --memory-limit 7.00GB --name dask-worker--${JOB_ID}-- --death-timeout 60 --resources processes=1

I define the following task:

def test_task(param_id):
    # cur_uuid = str(uuid.uuid4())
    cur_uuid = param_id
    import time
    print("\n\n################### STARTING NEW TASK ##############", cur_uuid, '#########')
    for i in range(12):
        print(cur_uuid, i, 30)
        time.sleep(5)
    return param_id

I submit jobs using this command: futures = [client.submit(test_task, param_id, resources={'processes':1}) for param_id in range(10000)]

But it seems that only one worker is actually doing anything while the other workers are completely idle (tail-fing the slurm out files)

Activity

  1. guillaumeeb commented on Feb 1, 2019

    @guillaumeeb
    Member
  2. wkerzendorf commented on Feb 1, 2019

    @wkerzendorf
    Author

    @guillaumeeb I've updated the main question.

  3. wkerzendorf commented on Feb 1, 2019

    @wkerzendorf
    Author

    I am specifically trying this with adaptive scaling and the worker 1 has been sitting there for two minutes not getting any of the 10k tasks and everything is running on the worker 0.

    That is worker 2s log:

    distributed.worker - INFO -              bokeh at:         172.16.2.130:43198
    distributed.worker - INFO - Waiting to connect to:   tcp://172.16.2.152:41753
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -               Threads:                          8
    distributed.worker - INFO -                Memory:                    7.00 GB
    distributed.worker - INFO -       Local Directory: /home/wek224/projects/tardis/nn/hesma/worker-qjv1h0ng
    distributed.worker - INFO - -------------------------------------------------
    distributed.worker - INFO -         Registered to:   tcp://172.16.2.152:41753
    distributed.worker - INFO - -------------------------------------------------
    distributed.core - INFO - Starting established connection
    distributed.worker - INFO - Stopping worker at tcp://172.16.2.130:33306
    distributed.nanny - INFO - Closing Nanny at 'tcp://172.16.2.130:37770'
    distributed.dask_worker - INFO - End worker

    That is what I see inside the notebook happening:

    DEBUG:removing worker name (dask-worker--14933947--) and job_id (14933947)
    
  4. wkerzendorf commented on Feb 1, 2019

    @wkerzendorf
    Author

    and then it relaunches a slurm job to get up to 20 workers again. So worker 1 does all the work while the others are spawned - live for sometime and then die again without having done anything.

  5. lesteve commented on Feb 4, 2019

    @lesteve
    Member

    Here are the things I suggest you try:

    • what happens if you don't use adaptive, i.e. remove cluster.adapt and use cluster.scale(num_workers_goes_here)?
    • please post a fully stand-alone snippet so we can try to reproduce. Fully stand-alone means we can copy and paste your snippet and try it on the SLURM clusters we have access to. This is invaluable for us and will increase the likelihood for you to get quality feed-back.
    • this should be part of the previous bullet points, but can you try replacing your multi-threaded function by a simple Python function (e.g. time.sleep) to see whether you are seeing the same behaviour

    I don't think this is part of the problem but you probably don't need job_extra=['--nodes=1', '--ntasks-per-node=1', '--cpus-per-task=8'].

  6. guillaumeeb commented on Feb 4, 2019

    @guillaumeeb
    Member

    This sounds weird and looks like the problem of @npaulson in #206.
    And you're both with Slurm.

    @wkerzendorf please follow @lesteve advices, maybe you can try snippet from #206 (comment).

  7. lesteve commented on Feb 4, 2019

    @lesteve
    Member

    This sounds weird and looks like the problem of @npaulson in #206.

    Yep completely agree. It'd be great to get to the bottom of this ...

  8. wkerzendorf commented on Feb 4, 2019

    @wkerzendorf
    Author

    Hey guys, in the process of debugging: I need the job extras as the cluster here does not like it another way: Plase do not specify --ntasks on prince cluster, try to use --nodes and --tasks-per-node together. The test task that I defined is at the top.

  9. wkerzendorf commented on Feb 4, 2019

    @wkerzendorf
    Author

    I'm also using the jupyter widget for scaling - I can do it in code if you guys think that this might be problematic.

  10. wkerzendorf commented on Feb 4, 2019

    @wkerzendorf
    Author

    @guillaumeeb @lesteve so I am now scaled it to two - but I do not see any print-out in the slurmXXX.outs. Does dask not let the print statements through? Should I define a logging function in my test task?

  11. guillaumeeb commented on Feb 4, 2019

    @guillaumeeb
    Member

    Have you worker job ended yet? With batch scheduler often you don't get the output befor the job ends.

    Have you access to the Dashboard? This could help to see if several workers are executing tasks.

  12. wkerzendorf commented on Feb 4, 2019

    @wkerzendorf
    Author

    does not seem to be the case. I have access to the dashboard - it seems to be executing - but nothing in the workers log (when I execute my code - I can definitely see that in the .out file - but I'm using logging).
    screen shot 2019-02-04 at 11 42 32 am

  13. lesteve commented on Feb 4, 2019

    @lesteve
    Member

    @wkerzendorf you have to help us help you ;-) ! Without a stand-alone snippet we are reduced to wild guesses which is not the most optimal way of spending our time ...

    I strongly suggest:

    • we look at one problem at a time in this issue. My understanding is that the original question was about the following: only part of the workers are used to run the computation, the rest of the workers do nothing. Correct me if I misunderstood so we can make sure we are all on the same page.
    • we start with something simple and increase complexity step by step as I suggested in my earlier message

    OK so let's start with something simple, single-core jobs with simple Python function. Can you run this in your notebook and post the output you get?

    import time
    import logging
    import socket
    import os
    from pprint import pprint
    
    from distributed import Client
    
    from dask_jobqueue import SLURMCluster
    
    
    def slow_increment(x):
        time.sleep(5)
        return {'result': x + 1,
                'host': socket.gethostname(),
                'pid': os.getpid(),
                'time': int(time.time() % 100)}
    
    
    cluster = SLURMCluster(walltime='01:00:00', memory='7 GB',
                           job_extra=['--nodes=1', '--ntasks-per-node=1'],
                           cores=1)
    
    cluster.scale(2)
    client = Client(cluster)
    
    nb_workers = 0
    while True:
        nb_workers = len(client.scheduler_info()["workers"])
        print('Got {} workers'.format(nb_workers))
        if nb_workers >= 2:
            break
        time.sleep(1)
    
    futures = client.map(slow_increment, range(8))
    
    print('client:', client)
    
    results = client.gather(futures)
    print('results:')
    pprint(results)
  14. wkerzendorf commented on Feb 4, 2019

    @wkerzendorf
    Author

    Here's what comes out. I think the issues seems to be more about the resources keywords that I used to ensure that only one task runs per worker.

    Got 0 workers
    Got 0 workers
    Got 0 workers
    Got 2 workers
    client: <Client: scheduler='tcp://172.16.2.133:44245' processes=2 cores=2>
    results:
    [{'host': 'c39-01', 'pid': 10826, 'result': 1, 'time': 46},
     {'host': 'c39-01', 'pid': 10827, 'result': 2, 'time': 46},
     {'host': 'c39-01', 'pid': 10826, 'result': 3, 'time': 51},
     {'host': 'c39-01', 'pid': 10827, 'result': 4, 'time': 51},
     {'host': 'c39-01', 'pid': 10826, 'result': 5, 'time': 57},
     {'host': 'c39-01', 'pid': 10827, 'result': 6, 'time': 57},
     {'host': 'c39-01', 'pid': 10826, 'result': 7, 'time': 62},
     {'host': 'c39-01', 'pid': 10827, 'result': 8, 'time': 62}]
    
  15. wkerzendorf commented on Feb 4, 2019

    @wkerzendorf
    Author

    I have also now run this setup and just changed to adapt (and taken out the while loop). When that happens it queues one job (which is not being scheduled because I think the scheduler would like more CPUs to be scheduled) even though the maximum is 3.

  16. 8 remaining items

  17. wkerzendorf commented on Feb 4, 2019

    @wkerzendorf
    Author

    I see a similar behavior now - it runs the first worker. then it spawns new workers and immediately kills them. I'm trying to see if it is the resources option but the cluster is very busy and it takes a while.

  18. wkerzendorf commented on Feb 4, 2019

    @wkerzendorf
    Author

    @guillaumeeb @lesteve - I'm pretty sure that the resources option is to blame. I ran it with and without resources option and with it the behaviour is that it kills the workers as soon as they are spawned because they are idle.
    I need the resources because I need my workers to execute something that needs 8 threads but only execute one of these tasks at a time on each SLURM job (I hope that makes sense). I can trick it into doing this by specifying

    SLURMCluster(walltime='01:00:00', memory='7 GB',
                           job_extra=['--nodes=1', '--ntasks-per-node=1', '--cpus-per-task=8'],
                           cores=1, )

    but I guess it would be good to fix that properly. Let me know how I can help more.

  19. wkerzendorf commented on Feb 4, 2019

    @wkerzendorf
    Author

    just an update - with my workaround it works (not using the resource option for now). It works amazingly well (with the nannies killing the workers as they reach their memory limit) - great framework - thank you!!! still interested in helping to get to the bottom of the resource problem.

  20. guillaumeeb commented on Feb 5, 2019

    @guillaumeeb
    Member

    Thanks @wkerzendorf. The other trick you used was the second solution for your need. The drawback is that you cannot have tasks that need different number of cores, whereas you could with --resources.

    So it seems you got the same problem as @leej3 in dask/distributed#1851. This is a distributed issue, I did not have time to dig deeper currently.

  21. wkerzendorf commented on Feb 5, 2019

    @wkerzendorf
    Author

    @guillaumeeb let me know if I should post something in dask distributed (I guess not as it already has an issue)

  22. guillaumeeb commented on Feb 11, 2019

    @guillaumeeb
    Member

    I guess it is not needed to post anything more in distributed. But if you can dig deeper the already opened issue and come with some solution, that would be really appreciated (I know, this is probably too much to ask for now).

  23. wkerzendorf commented on Feb 13, 2019

    @wkerzendorf
    Author

    @guillaumeeb I'm happy to dig deeper on a pair coding session with an experienced dasker. Alone I think I will get quickly lost. I'm also a willing beta tester 😉

  24. martiningram commented on Jul 30, 2019

    @martiningram

    I believe I have the same issue with resources. My goal is to run several jobs; each one requires a GPU and should be placed on a separate worker.

    I start a client & workers as follows:

    def get_slurm_dask_client(n_workers, n_cores, n_processes):
    
        cluster = SLURMCluster(cores=n_cores,
                               processes=n_processes,
                               memory='32GB',
                               project="abc",
                               walltime="1-0",
                               extra=['--resources GPU=1'],
                               queue="gpgpu",
                               job_extra=['--gres=gpu:1'])
    
        cluster.start_workers(n_workers)
        client = Client(cluster)
    
        return client

    This works fine. I then call this function like so:

            dask_client = get_slurm_dask_client(n_workers=4, n_cores=8,
                                                n_processes=1)
        for cur_dataset_name, cur_dataset in datasets.items():
            for cur_model_name, cur_model_fn in models.items():
    
                needs_gpu = 'mogp' in cur_model_name or 'sogp' in cur_model_name
                added_kwargs = dict()
                if needs_gpu:
                    added_kwargs['resources'] = {'GPU': 1}
    
                all_dask.append(
                    dask_client.submit(
                        run_evaluation, cur_model_name, cur_model_fn,
                        cur_dataset_name, cur_dataset, min_presences, test_run,
                        target_dir, **added_kwargs)
                )
    
        dask_client.gather(all_dask)

    This starts running and makes 4 workers on different slurm instances, which is all great. However, like the issue, only one of them actually ends up running, with the others just idling. I wonder if the resources aren't specified per worker, but only one of them gets them, or something?

    I tried the workaround suggested above, specifying cores=1, but while that works, in my case it does actually seem to use only one core, which makes my code run much more slowly.

    I'd appreciate any suggestions / help!

  25. lesteve commented on Jul 30, 2019

    @lesteve
    Member

    Can you create a separate issue please?

  26. martiningram commented on Jul 30, 2019

    @martiningram

    Sure, sorry, I didn't want to duplicate this one, but happy to do that.

  27. lesteve commented on Jul 30, 2019

    @lesteve
    Member

    Your problem may be related to the original issue, hard to tell really without investigating more and having a separate issue will help keeping our issue tracker tidy.

  28. martiningram commented on Jul 30, 2019

    @martiningram

    Got it -- done now, see: #304

  29. guillaumeeb commented on Aug 30, 2022

    @guillaumeeb
    Member

    Closing this issue as stale, and there are a lot of different problem in it. The last one raised is the adaptative scalign using resources, but if someone encounters it again, we should open a new issue.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions