Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ Here are a few more detailed examples

### Batch Scripts

**Simple One Node**
Example batch file with directives that reserve one node in the default queue, with 16 cores and exclusive use of the node:

<span id="example-sbatch-with-one-node-default-queue"></span>

```bash
#!/bin/bash
#SBATCH -N 1
Expand All @@ -60,6 +62,94 @@ Example batch file with directives that reserve one node in the default queue, w
<<shell commands that set up and run the job>>
```

**Modified Memory and Time**
The job below asks for 16GB and can run up to 48 hours.

<span id='example-sbatch-on-slurm-with-modified-memory-and-time'></span>

```bash
#!/bin/bash
#SBATCH --job-name=allthesmallthings
#SBATCH --time=48:00:00
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=20
#SBATCH --mem=16GB
```

**Using GPUs**
To modify your sbatch script for a GPU, you need to add both `--gres` and `--partition`

<span id='example-sbatch-script-using-slurm-with-gpu'></span>

```bash
#!/bin/bash
#SBATCH --job-name=cron
##SBATCH --begin=now+7days
##SBATCH --dependency=singleton
#SBATCH --time=00:02:00
#SBATCH --mail-type=FAIL
#SBATCH -p gpu
#SBATCH -c 1
#SBATCH --gres gpu:1

# Load modules here
ml load gromacs/2016.3

# Run your script
/bin/bash /scratch/users/pancakes/runMe.sh
```

**Long Running Jobs**

Let's say you have a long running job with low memory, and the memory grows over time. Here is an example that would make sure that the job goes for 3 days. The QOS (quality of service) directive tells the job manager that the job will be running longer than a day.

<span id='example-slurm-long-running-job-sbatch'></span>

```bash
#!/bin/bash
#SBATCH --job-name=normaljob
#SBATCH -p normal
#SBATCH --qos=long
#SBATCH --time=3-00:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=32
#SBATCH --mem=300000
ml load system devel
srun /bin/bash /scratch/users/minniemouse/myJob.sh
```

**Submit without Job File**
You can submit a job directly (on the command line) without a job file. The same SBATCH directives at the top become the parameter.

<span id='example-submission-without-jobfile-slurm'></span>

```bash
sbatch --job-name=$job_name -o $job_name.%j.out -e $job_name.%j.err /scratch/users/smiley/scripts/makeSmiles.sh ${file1} ${file2}
```

**Google Drive Sync**

<span id='example-google-drive-sync-with-sbatch-on-slurm'></span>

```bash
#!/bin/bash
#SBATCH --job-name=gdrive
#SBATCH --output=/home/users/julienc/logs/gdrive.out
#SBATCH -p agitler
#SBATCH --time=7-0 ## To be used with --qos=long
#SBATCH --cpus-per-task=1
#SBATCH --begin=now+48hour
#SBATCH --dependency=singleton

module load system gdrive
date

# Example of delete, where the string at the end is the file id on Google Drive
gdrive sync upload --keep-local --delete-extraneous $OAK/Shared/Potatoes/ sdhfshds3u39ur93rioneksfser
```


## Tools

<span id='question-what-tools-exist-to-help-with-using-slurm'></span> The following tools are useful for interacting or otherwise using SLURM.
Expand All @@ -78,3 +168,4 @@ Example batch file with directives that reserve one node in the default queue, w
- [AskCI Site](https://ask.ci)