Examples of cluster_info.json and cluster_script.sh scripts for various cluster workload managers
CryoSPARC can integrate with cluster scheduler systems. This page contains examples of integration setups.
Due to the many variations of cluster scheduler systems and their configurations, the examples here will need to be modified for your own specific use case.
When CryoSPARC launches a job to the cluster, the number of GPUs requested by the user is used in the submission script, but CryoSPARC does not know which specific devices it will be allocated and therefore each job simply tries to use GPUs with device numbers starting at zero. For example, a 2-GPU job will try to use GPUs [0, 1] when submitted to a cluster. It is the responsibility of the cluster system to correctly allocate requested GPU resources to CryoSPARC jobs while insulating those allocated resources from interference by other jobs. For this purpose, the SLURM scheduler, for example, can combine Generic Resource (GRES) management with (Linux) cgroup controls.
If your cluster does not properly allocate GPU resources, you may try to partially work around this using the following bash code snippet just before {{run_cmd}} in your cluster submission script template:
This loop will check which GPUs are currently idle (have no context) and will use those devices for the newly spawned job. This method is no substitute for a properly configured cluster resource allocation and therefore not recommended.
#!/usr/bin/env bash#### cryoSPARC cluster submission script template for SLURM## Available variables:## {{ run_cmd }} - the complete command string to run the job## {{ num_cpu }} - the number of CPUs needed## {{ num_gpu }} - the number of GPUs needed. ## Note: the code will use this many GPUs starting from dev id 0## the cluster scheduler or this script have the responsibility## of setting CUDA_VISIBLE_DEVICES so that the job code ends up## using the correct cluster-allocated GPUs.## {{ ram_gb }} - the amount of RAM needed in GB## {{ job_dir_abs }} - absolute path to the job directory## {{ project_dir_abs }} - absolute path to the project dir## {{ job_log_path_abs }} - absolute path to the log file for the job## {{ worker_bin_path }} - absolute path to the cryosparc worker command## {{ run_args }} - arguments to be passed to cryosparcw run## {{ project_uid }} - uid of the project## {{ job_uid }} - uid of the job## {{ job_creator }} - name of the user that created the job (may contain spaces)## {{ cryosparc_username }} - cryosparc username of the user that created the job (usually an email)## {{ job_type }} - CryoSPARC job type#### What follows is a simple SLURM script:#SBATCH --job-name cryosparc_{{ project_uid }}_{{ job_uid }}#SBATCH -n {{ num_cpu }}#SBATCH --gres=gpu:{{ num_gpu }}#SBATCH --partition=gpu#SBATCH --mem={{ (ram_gb*1000)|int }}MB#SBATCH --output={{ job_log_path_abs }}#SBATCH --error={{ job_log_path_abs }}{{ run_cmd }}
#!/bin/bash#### cryoSPARC cluster submission script template for PBS## Available variables:## {{ run_cmd }} - the complete command string to run the job## {{ num_cpu }} - the number of CPUs needed## {{ num_gpu }} - the number of GPUs needed. ## Note: the code will use this many GPUs starting from dev id 0## the cluster scheduler or this script have the responsibility## of setting CUDA_VISIBLE_DEVICES so that the job code ends up## using the correct cluster-allocated GPUs.## {{ ram_gb }} - the amount of RAM needed in GB## {{ job_dir_abs }} - absolute path to the job directory## {{ project_dir_abs }} - absolute path to the project dir## {{ job_log_path_abs }} - absolute path to the log file for the job## {{ worker_bin_path }} - absolute path to the cryosparc worker command## {{ run_args }} - arguments to be passed to cryosparcw run## {{ project_uid }} - uid of the project## {{ job_uid }} - uid of the job## {{ job_creator }} - name of the user that created the job (may contain spaces)## {{ cryosparc_username }} - cryosparc username of the user that created the job (usually an email)## {{ job_type }} - CryoSPARC job type#### What follows is a simple PBS script:#PBS -N cryosparc_{{ project_uid }}_{{ job_uid }}#PBS -l select=1:ncpus={{ num_cpu }}:ngpus={{ num_gpu }}:mem={{ (ram_gb*1000)|int }}mb:gputype=P100#PBS -o {{ job_log_path_abs }}#PBS -e {{ job_log_path_abs }}{{ run_cmd }}
#!/bin/bash## What follows is a simple UGE script:## Job Name#$ -N cryosparc_{{ project_uid }}_{{ job_uid }}## Number of CPUs (select 1 CPU always, and oversubscribe as GPU is per core value)##$ -pe smp {{ num_cpu }}#$ -pe smp 1## Memory per CPU core#$ -l m_mem_free={{ (ram_gb)|int }}G## Number of GPUs #$ -l gpu_card={{ num_gpu }}## Time limit 4 days#$ -l h_rt=345600## STDOUT/STDERR#$ -o {{ job_log_path_abs }}#$ -e {{ job_log_path_abs }}#$ -j y## Number of threadsexport OMP_NUM_THREADS={{num_cpu}}echo"HOSTNAME: $HOSTNAME"{{ run_cmd }}