Skip to content
Snippets Groups Projects
Commit f67c4cf2 authored by payno's avatar payno
Browse files

Dox: add example for defining "gpu_card"

parent 4a6836b2
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# How to launch a shell script to slurm using sluurp # How to launch a shell script to slurm using sluurp
The class to launch a shell script to slurm is `SBatchScriptJob` and with it you must provide: The class to launch a shell script to slurm is `SBatchScriptJob` and with it you must provide:
* `slurm_config`: configuration to slurl * `slurm_config`: configuration to slurl
* `script`: script to launch * `script`: script to launch
* `script_path`: where to save the script (if clean_script is set to True) then this script will be removed once processing is done. It can be useful to keep it for debugging * `script_path`: where to save the script (if clean_script is set to True) then this script will be removed once processing is done. It can be useful to keep it for debugging
* `working_directory`: working directory to provide to `SBATCH` when executing the script * `working_directory`: working directory to provide to `SBATCH` when executing the script
Once the job is created you can submit it to slurm using the `submit` function from `sluurp.executor` Once the job is created you can submit it to slurm using the `submit` function from `sluurp.executor`
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## slurm_config ## slurm_config
`slurm_config` must be provided as a dictionary and can contain the following keys: `slurm_config` must be provided as a dictionary and can contain the following keys:
* `cpu-per-task` (int): define number of cpu to require for each task * `cpu-per-task` (int): define number of cpu to require for each task
* `n_tasks` (int): define th enumber of tasks * `n_tasks` (int): define th enumber of tasks
* `memory` (int): memory in GB ( <=> `--mem` option in slurm) * `memory` (int): memory in GB ( <=> `--mem` option in slurm)
* `partition` (str): partition to be used * `partition` (str): partition to be used
* `n_gpus` (int): number of gpu to use * `n_gpus` (int): number of gpu to use
* `job_name` (str): name of the job ( <=> `-J` option in slurm) * `job_name` (str): name of the job ( <=> `-J` option in slurm)
* `walltime` (str): walltime ( <=> `-t` option in slurm) * `walltime` (str): walltime ( <=> `-t` option in slurm)
* `python_venv` (str): path to the python environment to source before executing script lines * `python_venv` (str): path to the python environment to source before executing script lines
* `modules` (tuple of str): module names to load before executing script lines * `modules` (tuple of str): module names to load before executing script lines
* `sbatch_extra_params`: dict: possible extra parameter to be used when cal the 'sbatch' command. For now handles 'export' only * `sbatch_extra_params`: dict: possible extra parameter to be used when calling the 'sbatch' command. For now handles 'export' and 'gpu_card'
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## example ## example
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import os import os
import tempfile import tempfile
from sluurp.executor import submit from sluurp.executor import submit
from sluurp.job import SBatchScriptJob from sluurp.job import SBatchScriptJob
sleep_time = 10 sleep_time = 10
with tempfile.TemporaryDirectory() as folder: with tempfile.TemporaryDirectory() as folder:
job = SBatchScriptJob( job = SBatchScriptJob(
script=(f"sleep {sleep_time}s", "echo 'succeed'"), script=(f"sleep {sleep_time}s", "echo 'succeed'"),
slurm_config={ slurm_config={
"partition": "nice", "partition": "nice",
"memory": 32, "memory": 32,
"job_name": "hello_world", "job_name": "hello_world",
}, },
script_path=os.path.join(folder, "script.sh"), script_path=os.path.join(folder, "script.sh"),
working_directory=folder, working_directory=folder,
) )
submit(job) submit(job)
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
``` ```
......
...@@ -15,7 +15,7 @@ slurm_config = { ...@@ -15,7 +15,7 @@ slurm_config = {
# "job_name": "test sluurp", # "job_name": "test sluurp",
# "python_venv": "/scisoft/tomotools/activate dev", # optional python environement to source before script command # "python_venv": "/scisoft/tomotools/activate dev", # optional python environement to source before script command
# "modules": ("tomotools", ), # optional module to source before script command # "modules": ("tomotools", ), # optional module to source before script command
# "sbatch_extra_params": {"export": "NONE"}, # extra parameters to provide to sbatch like 'export' # "sbatch_extra_params": {"export": "NONE", "gpu_card": "a40"}, # extra parameters to provide to sbatch like 'export'
} }
# step 1: launch the jobs # step 1: launch the jobs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment