Skip to content

Using different interfaces for scheduler and workers #382

Closed

Description

@kathoef

I am currently trying to setup a jobqueue cluster in a HPC environment in which available network interfaces on the compute nodes (where Dask workers live) and the login nodes (where the scheduler lives) are not the same.

Available network interfaces

  • on the compute nodes there are lo, ib0, but no ib1 and no eth{0,1}
  • whereas on the login nodes there are lo, ib1, eth0, and eth1

Starting a jobqueue cluster with a basic workflow of

import dask_jobqueue
import dask.distributed as dask_distributed
jobqueue_cluster = dask_jobqueue.SLURMCluster(cores=6, memory='24GB',
                                              project='esmtst', queue='devel',
                                              interface='ib0')
client = dask_distributed.Client(jobqueue_cluster)
jobqueue_cluster.scale(jobs=1)

causes the following error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-b93ee7f2ce8e> in <module>
----> 1 jobqueue_cluster = dask_jobqueue.SLURMCluster(cores=6, memory='24GB',
      2                                               project='esmtst', queue='devel',
      3                                               interface='ib0')

/p/project/cesmtst/hoeflich1/miniconda3/envs/Dask-jobqueue_v2020.02.10/lib/python3.8/site-packages/dask_jobqueue/core.py in __init__(self, n_workers, job_cls, loop, security, silence_logs, name, asynchronous, interface, host, protocol, dashboard_address, config_name, **kwargs)
    446             worker["group"] = ["-" + str(i) for i in range(kwargs["processes"])]
    447
--> 448         self._dummy_job  # trigger property to ensure that the job is valid
    449
    450         super().__init__(

/p/project/cesmtst/hoeflich1/miniconda3/envs/Dask-jobqueue_v2020.02.10/lib/python3.8/site-packages/dask_jobqueue/core.py in _dummy_job(self)
    473         except AttributeError:
    474             address = "tcp://<insert-scheduler-address-here>:8786"
--> 475         return self.job_cls(
    476             address or "tcp://<insert-scheduler-address-here>:8786",
    477             name="name",

/p/project/cesmtst/hoeflich1/miniconda3/envs/Dask-jobqueue_v2020.02.10/lib/python3.8/site-packages/dask_jobqueue/slurm.py in __init__(self, queue, project, walltime, job_cpu, job_mem, job_extra, config_name, *args, **kwargs)
     39             job_extra = dask.config.get("jobqueue.%s.job-extra" % config_name)
     40
---> 41         super().__init__(*args, config_name=config_name, **kwargs)
     42
     43         header_lines = []

/p/project/cesmtst/hoeflich1/miniconda3/envs/Dask-jobqueue_v2020.02.10/lib/python3.8/site-packages/dask_jobqueue/core.py in __init__(self, scheduler, name, cores, memory, processes, nanny, interface, death_timeout, local_directory, extra, env_extra, header_skip, log_directory, shebang, python, job_name, config_name, **kwargs)
    195         if interface:
    196             extra = extra + ["--interface", interface]
--> 197             kwargs.setdefault("host", get_ip_interface(interface))
    198         else:
    199             kwargs.setdefault("host", "")

/p/project/cesmtst/hoeflich1/miniconda3/envs/Dask-jobqueue_v2020.02.10/lib/python3.8/site-packages/distributed/utils.py in get_ip_interface(ifname)
    181     if ifname not in net_if_addrs:
    182         allowed_ifnames = list(net_if_addrs.keys())
--> 183         raise ValueError(
    184             "{!r} is not a valid network interface. "
    185             "Valid network interfaces are: {}".format(ifname, allowed_ifnames)

ValueError: 'ib0' is not a valid network interface. Valid network interfaces are: ['lo', 'ib1', 'eth0', 'eth1']

Workaround as suggested in #207 (comment) doesn't work, because Dask distributed doesn't like interface and host to be set at the same time.

Activity

  1. lesteve commented on Feb 13, 2020

    @lesteve
    Member

    Workaround as suggested in #207 (comment) doesn't work, because Dask distributed doesn't like interface and host to be set at the same time.

    Maybe it worked in the past for some combination of dask-jobqueue and distributed but not anymore.

    I think the best fix would be to have a scheduler_options parameter as mentioned in #355 (comment).

  2. guillaumeeb commented on Feb 21, 2020

    @guillaumeeb
    Member

    @kathoef thanks for raising this issue. This is a major problem. If @hawk-sf is not up to it in #355, would you be willing to contribute a fix for this issue?

  3. added this to the 0.7.1 milestone on Feb 21, 2020
  4. added
    bug
    on Feb 21, 2020
  5. kathoef commented on Feb 25, 2020

    @kathoef
    MemberAuthor

    I think the best fix would be to have a scheduler_options parameter as mentioned in #355 (comment).

    Thank you for having pointed this out @lesteve! Last week (by digging through the code in Dask jobqueue and Dask distributed, and with the help of the system admins on login and compute node network locations) I was finally able to make it work. The workaround is to avoid the interface keyword and to set all IP addresses explicitly:

    import dask_jobqueue, os
    import dask.distributed as dask_distributed
    jobqueue_cluster = dask_jobqueue.SLURMCluster(
        cores=6, memory='24GB',
        project='esmtst', queue='esm',
        # correctly passed down to scheduler dictionary
        host=os.environ['HOSTNAME'],
        # using Dask worker low-level options
        extra=['--host ${SLURMD_NODENAME}.ib.juwels.fzj.de'] 
    )
    client = dask_distributed.Client(jobqueue_cluster)
    jobqueue_cluster.scale(jobs=1)

    @kathoef thanks for raising this issue. This is a major problem. If @hawk-sf is not up to it in #355, would you be willing to contribute a fix for this issue?

    Thank you @guillaumeeb and yes, I could probably do that. (Not before next week, though.)

  6. lesteve commented on Mar 4, 2020

    @lesteve
    Member

    FYI in #384, I have a PR to allow to do that. You should be able to do something like this:

    import dask_jobqueue, os
    import dask.distributed as dask_distributed
    jobqueue_cluster = dask_jobqueue.SLURMCluster(
        cores=6, memory='24GB',
        project='esmtst', queue='esm',
        # interface for the workers
        interface='ib0',
        # interface for the scheduler (not sure whether ib1 is the right interface for you)
        scheduler_options={'interface': 'ib1'}
    )
    
    client = dask_distributed.Client(jobqueue_cluster)
    jobqueue_cluster.scale(jobs=1)

    In any case @kathoef if you could double-check this works on your cluster that would be much appreciated. You need to install dask-jobqueue from the PR branch, for example pip install git+https://github.com/lesteve/dask-jobqueue@add-scheduler-options

  7. kathoef commented on Mar 4, 2020

    @kathoef
    MemberAuthor

    Yes, great! I will try this out tomorrow.

  8. lesteve commented on Mar 6, 2020

    @lesteve
    Member

    @kathoef have you had the chance to try my snippet on your cluster? I would greatly appreciate if you took the time to do that. Or maybe you could ping someone else that is using dask-jobqueue on your cluster?

    If you are busy with other things, I would completely understand, no worries at all! I'll try to remind you in a week or so.

  9. kathoef commented on Mar 6, 2020

    @kathoef
    MemberAuthor

    I am at it now, actually! And I'll report on it before I leave into the weekend. :)

  10. quasiben commented on Mar 6, 2020

    @quasiben
    Member

    The ib0 interface is an Infiniband connection correct? Is this what you are ultimately after, using Infiniband ?

  11. lesteve commented on Mar 6, 2020

    @lesteve
    Member

    I don't know @kathoef's cluster but I think the convention is that ib<something> is an Infiniband interface indeed.

    In my experience, I have used ib<something> in dask-jobqueue just because there is this vague feeling that Infiniband is faster.

    I have to admit, I haven't really tested whether that was the case and I don't have any good insights whether at least some things will be faster (e.g. data transfer between Dask scheduler and Dask workers). If you have any insights on this @quasiben that would be greatly appreciated!

  12. quasiben commented on Mar 6, 2020

    @quasiben
    Member

    @lesteve I think to take advantage of Infiniband you would either need to write explicit c extensions for IB verbs/RDMA or use something like UCX/UCX-Py. I would not have expected that us interface=ib0 would work at all -- in fact, I would've expected this to fail. Did this at least work for you ?

  13. lesteve commented on Mar 6, 2020

    @lesteve
    Member

    Yep interface='ib0' works for me and many others. For example ib0 is used in quite a few of real-world examples: https://jobqueue.dask.org/en/latest/configurations.html

  14. quasiben commented on Mar 6, 2020

    @quasiben
    Member

    Hmm, perhaps things work because most devices are configured for EoIB (Ethernet over IB) which maybe gets you some gains? I'll ask some folks I work with for their thoughts and report back.

    You can also see IB transfers if you watch directories like the following:

    cat /sys/class/infiniband/mlx5_*/ports/1/counters/port_rcv_packets

    At your note that things worked, I modified a small client/server test with python sockets connected to an Infiniband device and saw no transfers.

    server
    import datetime
    import socket
    
    HOST = '10.33.225.163'
    PORT = 50000
    BUFFER = 4096
    
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.bind((HOST,PORT))
    sock.listen(0)
    print('listening at %s:%s\n\r' %(HOST, PORT))
    
    while True:
        client_sock, client_addr = sock.accept()
    
        starttime = datetime.datetime.now()
        print(starttime, end="")
        print('%s:%s connected\n\r' % client_addr)
    
        count = 0
        while True:
            data = client_sock.recv(BUFFER)
            if data:
                count += len(data)
                del data
                continue
    
            client_sock.close()
    
            endtime = datetime.datetime.now()
            print(endtime)
            print('%s:%s disconnected\n\r' % client_addr)
    
            print('bytes transferred: %d' % count)
            delta = endtime - starttime
            delta = delta.seconds + delta.microseconds / 1000000.0
            print('time used (seconds): %f' % delta)
            print('averaged speed (MB/s): %f\n\r' % (count / 1024 / 1024 / delta))
            break
    
    sock.close()
    Client
    import datetime
    import socket
    
    HOST = '10.33.225.163'
    PORT = 50000
    BUFFER = 4096
    
    testdata = b'x' * BUFFER * 4
    
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((HOST,PORT))
    for i in range(1, 1000000):
        sock.send(testdata)
    sock.close()
  15. kathoef commented on Mar 6, 2020

    @kathoef
    MemberAuthor

    FYI in #384, I have a PR to allow to do that. You should be able to do something like this:

    import dask_jobqueue, os
    import dask.distributed as dask_distributed
    jobqueue_cluster = dask_jobqueue.SLURMCluster(
        cores=6, memory='24GB',
        project='esmtst', queue='esm',
        # interface for the workers
        interface='ib0',
        # interface for the scheduler (not sure whether ib1 is the right interface for you)
        scheduler_options={'interface': 'ib1'}
    )
    
    client = dask_distributed.Client(jobqueue_cluster)
    jobqueue_cluster.scale(jobs=1)

    In any case @kathoef if you could double-check this works on your cluster that would be much appreciated. You need to install dask-jobqueue from the PR branch, for example pip install git+https://github.com/lesteve/dask-jobqueue@add-scheduler-options

    I have checked it now! I had to make an additional change to make it work, however. The code still fails with the error I had posted initially, i.e. the scheduler network location is set from an interface name that only exists in the compute node scope of the Dask workers.

    I have commited and pushed my solution here: https://github.com/kathoef/dask-jobqueue/tree/add-scheduler-options-kathoef (It looked save to me to delete the else-statement that sets an empty host, but please check that.)

  16. lesteve commented on Mar 7, 2020

    @lesteve
    Member

    Thanks a lot for checking, I appreciate you taking the time late on a Friday!

    OK that is weird that you get the same error or maybe I got something wrong in my PR. That would be great if you could:

    • paste the output of python -c 'import dask_jobqueue; print(dask_jobqueue.__version__)' (the idea is to make sure that you are using my branch)
    • paste the full stack-trace of the error message you get

    (no hurry and no pressure to do it before Monday though)

  17. lesteve commented on Mar 7, 2020

    @lesteve
    Member

    Thanks for the info @quasiben! This networking stuff is something I am really fuzzy about, but I would definitely like to learn a bit more about.

  18. guillaumeeb commented on Mar 7, 2020

    @guillaumeeb
    Member

    @quasiben

    perhaps things work because most devices are configured for EoIB (Ethernet over IB) which maybe gets you some gains?

    Yep, that's exactly that. You'll get close to Infinity Band bandwith, but not full RDMA power and low latencies, as you said :

    I think to take advantage of Infiniband you would either need to write explicit c extensions for IB verbs/RDMA or use something like UCX/UCX-Py

    That's why we are interested of potential gains we would have with using UCX. ib0 or ib1 are generally IPoverIB interface as you said. Adancing with #371 would be great!

    @lesteve thanks for all your recent work!

  19. kathoef commented on Mar 9, 2020

    @kathoef
    MemberAuthor

    Thanks a lot for checking, I appreciate you taking the time late on a Friday!

    OK that is weird that you get the same error or maybe I got something wrong in my PR. That would be great if you could:

    • paste the output of python -c 'import dask_jobqueue; print(dask_jobqueue.__version__)' (the idea is to make sure that you are using my branch)
    • paste the full stack-trace of the error message you get

    (no hurry and no pressure to do it before Monday though)

    Thank you for your very quick reply @lesteve! Actually I have checked quite carefully if the correct jobqueue code was used. The code still fails (for the HPC system I use) because:

    The function get_ip_interface() called here tries to retrieve the IP address of an interface using psutils here that does not exist in the scope of the login nodes where the Dask worker job script is generated. I'd like to highlight again that the only existing network interface on login nodes is ib1 and on compute nodes is ib0, respectively, and that IP address retrieval works only if code is executed in the correct (system hardware) scope.

    According to these changes the host argument is now obsolete, and should not be used anymore outside of the scheduler dictionary argument? If that's the case then I think it would indeed be totally fine to simply delete the code lines as I have done here in extension to your solution.

  20. lesteve commented on Mar 10, 2020

    @lesteve
    Member

    OK I think I got it thanks for your message @kathoef! Until now I could not figure out why the workers interface would be used on the node where the scheduler runs.

    The problem is that .dummy_job is called inside JobQueueCluster.__init__ so that happens on the node the scheduler runs and .dummy_job uses the workers interface ... note .dummy_job is only here for .job_script() which is useful for debugging.

    I need to think more how to find a work-around for this ... it may be worth for me to try to reproduce the problem in a docker-compose setup so that I can debug more easily.

  21. kathoef commented on Mar 11, 2020

    @kathoef
    MemberAuthor

    I need to think more how to find a work-around for this ... it may be worth for me to try to reproduce the problem in a docker-compose setup so that I can debug more easily.

    I think actually it would be a little bit of an overkill to debug this with a Docker compose setup. If it is helpful and if you don't mind (and as I have indeed capacity for such tasks this week!) I could try to develop a simple pytest solution that covers the network interface setup of my HPC cluster.

    Actually, I have the feeling (at least for the 0.7.0 code, I haven't had the time to do this for the code in #384) that currently what I would call "scopes" are, or might be, "violated" at several places, and that some things could be cleaned up in that regard. I could try to come up with a list of suggestions on that matter? (For which a rather fresh perspective might be helpful.)

  22. kathoef commented on Mar 11, 2020

    @kathoef
    MemberAuthor

    Also, it would be really nice if the new scheduler options could be set in a configuration file. I am also working on jobqueue defaults for HPC centers our group and others are working on and if I understand it correctly, currently on the HPC cluster we discuss here, one would always have to explicitely set the scheduler options in the cluster set up call. From a user perspective, however, it would be great if it was possible to do

    jobqueue_cluster = dask_jobqueue.SLURMCluster(
        config_name='juwels-jobqueue-config',
        project='<project>', # specify budget name
        queue='<queue>', # choose queue by available resources
    )

    and have everything specific to the machine hardware set up done in the background. Can/Should this be added in #384 or at a later point?

  23. lesteve commented on Mar 11, 2020

    @lesteve
    Member

    Actually, I have the feeling (at least for the 0.7.0 code, I haven't had the time to do this for the code in #384) that currently what I would call "scopes" are, or might be, "violated" at several places, and that some things could be cleaned up in that regard. I could try to come up with a list of suggestions on that matter? (For which a rather fresh perspective might be helpful.)

    Not sure what you mean by "violated scopes", but there is certainly room for improvement and help on dask-jobqueue would be more than welcome indeed! Something you have to bear in mind is that testing dask-jobqueue is not trivial, each cluster have their own quirks so that sometimes there is some code that is not tested but is useful. If you have suggestion on how to improve testing, this would be more than welcome as well!

    I think actually it would be a little bit of an overkill to debug this with a Docker compose setup.

    We already have a docker-compose setup to test dask-jobqueue on Travis (see https://github.com/dask/dask-jobqueue/tree/master/ci for more details), which is why I was mentioning docker-compose. I am guessing (but I don't know for sure) that adding a network interface to the worker docker image that does not exist on the scheduler docker image is not that hard.

    Also, it would be really nice if the new scheduler options could be set in a configuration file.

    That would make sense. I am not planning to include it in #384 to keep it simple. But I would welcome a PR on this! My thoughts on this: probably this should be nested inside the slurm section in ~/.config/dask/jobqueue.yaml, i.e. something like:

    jobqueue:
      slurm:
        name: dask-worker
        walltime: '00:30:00'
        ...
    
        scheduler_options:
          interface: eth1
          dashboard_address: :8787
    

    dask.config may just be able to tackle this just fine.

  24. kathoef commented on Mar 16, 2020

    @kathoef
    MemberAuthor

    Thanks for commenting my thoughts, @lesteve and @guillaumeeb! And sorry for getting back later than I had hoped... in the following you find some thoughts on how I would test for the behaviour that is necessary on the HPC cluster I am working on, and how I would implement that.

    I have pushed the tests for what I would call intended network interface argument behaviour here. These fail for Dask jobqueue 0.7.0 and for PR #384, because both codes make the (invalid!) assumption that the Dask worker interface can be used to also set the network location of the scheduler, which for PR #384 still happens e.g. here.

    The test passes if either host or interface in the scheduler_options are explicitely set, because in this case the Dask worker interface is not anymore passed and set as scheduler network location. However, I think requiring the user to explicitely set scheduler_options to allow arbitrary Dask worker interface names is not a straightforward implementation of this feature.

    Generally, if no network interfaces are set, the scheduler and the workers operate via the local default network devices (see e.g. ip r or netstat -r on Linux systems), which I think should remain the default behaviour for the scheduler object, if scheduler_options are not set.

  25. lesteve commented on Mar 16, 2020

    @lesteve
    Member

    @kathoef could you test #384 again with my snippet #382 (comment) ?

    I think I removed the problematic code that was expecting the worker interface to exist on the scheduler even when using scheduler_options.

    Thanks for your tests, I had a quick look at them and they help to clarify what you have in mind. You are correct that they will fail with #384.

    interface sets the interface to use both on the scheduler and the workers. The reason behind it is that in the majority of clusters, there is a common network interface that you can use both on the login node and the compute nodes. If there is not such a common network interface, the approach of #384 is to say interface is both for scheduler and workers but if you don't have such a common interface on your cluster, you can override the interface for the scheduler by using scheduler_options.

    I kind of agree it doesn't feel ideal, but I am afraid I don't see a better way forward at the moment. Changing the meaning of interface to mean "worker-only interface" would potentially break existing code.

  26. lesteve commented on Mar 23, 2020

    @lesteve
    Member

    @kathoef could you test #384 again with my snippet #382 (comment) ?

    @kathoef I completely understand if you have other priorities! I merged #384 and it would be great if you could confirm my snippet above works for you. Just for completeness you need to install the master branch for example with:

    pip install git+https://github.com/dask/dask-jobqueue
    
  27. kathoef commented on Mar 26, 2020

    @kathoef
    MemberAuthor

    Sorry for the late reply, I have tested the code with your snippet, and it works on my cluster without problems now. 👍

    I kind of agree it doesn't feel ideal, but I am afraid I don't see a better way forward at the moment. Changing the meaning of interface to mean "worker-only interface" would potentially break existing code.

    This is true! However, I think, because Dask jobqueue is a high-level tool, and not a low-level base library, that introducing breaking changes is not excessively critical, as long as intended usage patterns are well documented (and error messages are indicative). I personally would always favour solutions that disentangle components, thus increasing the clarity/linearity of code/information flow. (Also, generally, code that is not written, does not fail.)

    But I can also see why to decide differently on this aspect. Thanks for your work on adding the scheduler options feature, @lesteve! I will continue your work with #400 now. :)

  28. lesteve commented on Mar 26, 2020

    @lesteve
    Member

    Sorry for the late reply, I have tested the code with your snippet, and it works on my cluster without problems now. +1

    Great, thanks for the confirmation!

    Thanks for your work on adding the scheduler options feature, @lesteve! I will continue your work with #400 now. :)

    Don't hesitate to ping me if you get stuck! By the way Dask-Jobqueue 0.7.1 was released this morning and it has the scheduler_options feature. It is on PyPI not on conda-forge yet.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions