Slurm Script Beginner GPU
The Slurm script generally follows this format:
#!/bin/bash # Declaring Slurm Configuration Options # Loading Software/Libraries # Running Code
1. Sample Slurm Script
For example, let’s create a sample Slurm job script and submit the job to the cluster. First, create an empty file using vim editor(or your favourite editor) and insert the following script and save it using .slurm or .sh extension (for example, myjob.slurm or myjob.sh):
#!/bin/bash #SBATCH --job-name=gpu_test # Job name #SBATCH --qos=short # qos #SBATCH -p gpu # partition #SBATCH --output=gpu_test.out # Output file to store results #SBATCH --ntasks=1 # Number of tasks (1 task in this case) #SBATCH --gres=gpu:1 # Request 1 GPU for this job #SBATCH --time=00:05:00 # Set the maximum job runtime to 5 minutes # Display information about the GPU using nvidia-smi echo "Testing GPU resources with nvidia-smi" nvidia-smi
In this example, we run the bash command nvidia-smi.