Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Documentation] Call shell scripts with extra resources inside the submitted Python function #567

Open
jan-janssen opened this issue Feb 10, 2025 · 0 comments

Comments

@jan-janssen
Copy link
Member

For SLURM each call of srun creates a new job step, so there is no need to assign any resources to the specific Python function, just assign the resources to the external shell script directly.

For flux there is the option to use nested executors:
https://executorlib.readthedocs.io/en/latest/3-hpc-job.html#nested-executors

Still this option can also be assigned during the submission - just like all the other options:

from executorlib import FluxJobExecutor

def get_available_gpus(lst):
    import socket
    from tensorflow.python.client import device_lib
    local_device_protos = device_lib.list_local_devices()
    return [
        (x.name, x.physical_device_desc, socket.gethostname())
        for x in local_device_protos if x.device_type == "GPU"
    ] + lst

with FluxJobExecutor() as exe:
    fs = []
    for i in range(1, 4):
        fs = exe.submit(
            get_available_gpus,
            lst=fs,
            resource_dict={"cores": 1, "gpus_per_core": 1, "flux_executor_nesting": True},
        )
    print(fs.result())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant