Skip to content

SLURM cluster running only one worker when resources specified #304

Closed

Description

@martiningram

Hi there,

I believe I have the same issue with resources as #230. 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 in #230, 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!

Activity

  1. lesteve commented on Jul 30, 2019

    @lesteve
    Member

    Thanks a lot for creating a new issue!

    However, like the issue, only one of them actually ends up running, with the others just idling

    What do you mean by idling? How many jobs do you see with sstat? What do you see when you look at your cluster object for example print(cluster) or cluster + Shift-Enter inside a notebook.

    I wonder if the resources aren't specified per worker, but only one of them gets them, or something?

    The resources are specified by dask worker. IIRC when you use cores=8, processes=1 and do cluster.scale(1) you have one dask worker with 8 threads. If you use cores=4, processes=2 and do cluster.scale(2) you have 2 dask workers with 4 threads each. One way to look at the number of dask workers you have with len(client.scheduler_info()['workers']) (it may be in the cluster widget inside a notebook too, not sure).

    Note that if you have one GPU resource per worker as you do and you use .submit specifying the resource {'GPU': 1}, that means that only one task can run in parallel on this worker. If you do not specify resource in .submit, you can run 8 tasks in parallel.

    The distributed resource doc is here. If you see a way to improve the doc there or the doc in dask-jobqueue, let us know!

  2. guillaumeeb commented on Jul 30, 2019

    @guillaumeeb
    Member

    Hi,

    #230 was in the end a problem when using resources with adaptive scaling. You don't seem to be using adaptive mode.

    I'll recommand to use scale instead of start_worker, but mainly to make sure all the workers are started before submitting the tasks. Job stealing with resources doesn't seem to work well, so the first worker to start may be assigned all the tasks before others are set up. You can use client.wait_for_workers to do this.

  3. guillaumeeb commented on Feb 1, 2020

    @guillaumeeb
    Member

    Closing this one as stale. @martiningram feel free to reopen if you still have problems.

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