snakemake / snakemake-executor-plugin-slurm

A Snakemake executor plugin for submitting jobs to a SLURM cluster
MIT License
18 stars 19 forks source link

sbatch: error: Batch job submission failed: Invalid feature specification #104

Closed Luke-ebbis closed 5 months ago

Luke-ebbis commented 5 months ago

I have been trying to run my snakemake on a HPC cluster. But I cannot figure out how I can run it in a non-interactive session with a gpu.

The rule I submitted was:

snakemake --use-conda --workflow-profile workflow/profiles/slurm results/data/subunits/subunits/processed-pairs/A0_A0
Using workflow specific profile workflow/profiles/slurm for setting default command line arguments.
Building DAG of jobs...
SLURM run ID: 74d44437-b36b-4eef-80ff-e4e167ab6c50
Using shell: /usr/bin/bash
Provided remote nodes: 100
Job stats:
job          count
---------  -------
colabfold        1
total            1

Select jobs to execute...
Execute 1 jobs...

[Fri Jun 14 15:20:07 2024]
rule colabfold:
    input: results/data/subunits/subunits/fasta-pairs/A0_A0.fasta, results/checkpoints/setup_cuda
    output: results/data/subunits/subunits/processed-pairs/A0_A0
    jobid: 0
    reason: Missing output files: results/data/subunits/subunits/processed-pairs/A0_A0
    wildcards: protein_complex=subunits, grouping=pairs, fasta_file=A0_A0
    resources: mem_mb=28610, mem_mib=30518, disk_mb=5000, disk_mib=4769, tmpdir=<TBD>, runtime=24, tasks=1, mpi=sbatch, slurm_partition=gpu1, gres=gpu:a100:1, constraint=gpu, cpus_per_task=10, mem=30G, slurm_account=mpmp_gpu

MPI job detected, but no 'tasks_per_node' or 'nodes' specified. Assuming 'tasks_per_node=1'.Probably not what you want.
WorkflowError:
SLURM job submission failed. The error message was sbatch: error: option «constraint=gpu» given, but not a proper value for option «gres»
sbatch: error: Batch job submission failed: Invalid feature specification

I think that this rule is akin to the jobscript that my HPC support gives as an example (see Example jobscript). When I remove the gres option, the rule is submitted as an interactive session.

JobID           JobName  Partition    Account  AllocCPUS      State ExitCode 
------------ ---------- ---------- ---------- ---------- ---------- -------- 
11248531     f9029e40-+      small   mpmp_cpu          0    PENDING      0:0 

The submission details are as follows

JobId=11248531 JobName=f9029e40-0b6d-4f4c-af21-e885687a0e2a
   UserId=sibak(81507) GroupId=mpmp(19600) MCS_label=N/A
   Priority=5351613 Nice=0 Account=mpmp_cpu QOS=n0001
   JobState=CANCELLED Reason=Priority Dependency=(null)
   Requeue=1 Restarts=0 BatchFlag=1 Reboot=0 ExitCode=0:0
   RunTime=00:00:00 TimeLimit=00:24:00 TimeMin=N/A
   SubmitTime=2024-06-14T15:29:46 EligibleTime=2024-06-14T15:29:46
   AccrueTime=2024-06-14T15:29:46
   StartTime=2024-06-14T15:30:32 EndTime=2024-06-14T15:30:32 Deadline=N/A
   SuspendTime=None SecsPreSuspend=0 LastSchedEval=2024-06-14T15:30:18 Scheduler=Main
   Partition=small AllocNode:Sid=raven01:83136
   ReqNodeList=(null) ExcNodeList=(null)
   NodeList=
   NumNodes=1 NumCPUs=10 NumTasks=1 CPUs/Task=10 ReqB:S:C:T=0:0:*:1
   ReqTRES=cpu=10,mem=28610M,node=1,billing=10
   AllocTRES=(null)
   Socks/Node=* NtasksPerN:B:S:C=0:0:*:1 CoreSpec=*
   MinCPUsNode=10 MinMemoryNode=28610M MinTmpDiskNode=0
   Features=cpu DelayBoot=00:00:00
   OverSubscribe=OK Contiguous=0 Licenses=(null) Network=(null)
   Command=(null)
   WorkDir=/raven/ptmp/sibak/jobs/combfold-pipeline/Combfold-pipline-devel
   Comment=rule_colabfold_wildcards_subunits_pairs_A0_A0 
   StdErr=/raven/ptmp/sibak/jobs/combfold-pipeline/Combfold-pipline-devel/.snakemake/slurm_logs/rule_colabfold/subunits_pairs_A0_A0/11248531.log
   StdIn=/dev/null
   StdOut=/raven/ptmp/sibak/jobs/combfold-pipeline/Combfold-pipline-devel/.snakemake/slurm_logs/rule_colabfold/subunits_pairs_A0_A0/11248531.log
   Power=
   TresPerTask=cpu:10

Does someone know why constraint and gres conflict?

Files

Example jobscript

Details

```sh #!/bin/bash -l # Provided by: # https://docs.mpcdf.mpg.de/doc/computing/raven-user-guide#batch-jobs-using-gpus # Standard output and error: #SBATCH -o ./job.out.%j #SBATCH -e ./job.err.%j # Initial working directory: #SBATCH -D ./ # Job name #SBATCH -J test_gpu # #SBATCH --ntasks=1 #SBATCH --constraint="gpu" # # --- default case: use a single GPU on a shared node --- #SBATCH --gres=gpu:a100:1 #SBATCH --cpus-per-task=18 #SBATCH --mem=125000 # # --- uncomment to use 2 GPUs on a shared node --- # #SBATCH --gres=gpu:a100:2 # #SBATCH --cpus-per-task=36 # #SBATCH --mem=250000 # # --- uncomment to use 4 GPUs on a full node --- # #SBATCH --gres=gpu:a100:4 # #SBATCH --cpus-per-task=72 # #SBATCH --mem=500000 # #SBATCH --mail-type=none #SBATCH --mail-user=userid@example.mpg.de #SBATCH --time=12:00:00 module purge module load intel/21.2.0 impi/2021.2 cuda/11.2 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK} srun ./cuda_executable ```

Slurm configuration

Details

```yaml executor: slurm latency-wait: 60 jobname: "{rule}.{jobid}" jobs: 100 default-resources: - mem_mb=2000 - runtime='1440' - tasks=2 - mpi="sbatch" - slurm_partition="gpu1" - disk_mb=5000 ```

Luke-ebbis commented 5 months ago

So I found that this issue was similar to #52. After changing gres for `slurm_extra-'--gres'. It seems to work:

## colabfold:
##    Calculate the protein structures of the fasta files using Colabfold.
##
rule colabfold:
  conda:
    "envs/fold.yml"
  input:
    fasta="results/data/{protein_complex}/subunits/fasta-{grouping}/{fasta_file}.fasta",
    cuda="results/checkpoints/setup_cuda"
  resources:
    mem_mb=32000,
    slurm_extra= "'--gres=gpu:a100:1'",
    constraint="gpu",
    tasks="1",
    cpus_per_task=10,
    mem="30G",
    slurm_partition='gpu1',
    runtime='1440',
    slurm_account="mpmp_gpu",
  # threads: 10
  params:
    number_of_models=config['colabfold']['number_of_models']
  output:
    directory("results/data/{protein_complex}/subunits/processed-{grouping}/{fasta_file}")
  shell:
    """
    echo "Starting colabfold, please see {output}/log.txt for the log"
    colabfold_batch {input.fasta} {output} --num-models {params.number_of_models}
    """

see

sacct -j 11248616
JobID           JobName  Partition    Account  AllocCPUS      State ExitCode 
------------ ---------- ---------- ---------- ---------- ---------- -------- 
11248616     7c0303fa-+       gpu1   mpmp_gpu         20    RUNNING      0:0 
11248616.ba+      batch              mpmp_gpu         20    RUNNING      0:0 
11248616.ex+     extern              mpmp_gpu         20    RUNNING      0:0 

Can this be more clear in the documentation (where can I make a PR to update the docs?)

Again thanks for providing this great software!

cmeesters commented 5 months ago

Erm, nice that it is working for you. Thank you for your offer - you can always fork and do a merge request, like with any other repository. Note, however, that sbatch is no MPI-starter and that slurm_extra is a documented feature (albeit, that some documentation changes are already pending and this needs a better description, as I concede).

One hint, if you allow me: Strive to build portable workflows, just put your resources in a workflow profile. I would be really pleased to find a workflow for structure prediction in the Snakemake workflow catalogue.