HPC4 - SUBMIT YOUR FIRST SLURM JOB

Simple Python job example

1. SSH to HPC4 login node, please check here: How to login

2. Save the below example python code as test.py in your home directory

import numpy as np
N = 3
X = np.random.randn(N, N)
print("X =\n", X)
print("Inverse(X) =\n", np.linalg.inv(X))

3. If you would like to try your code in login node, type below:

% python test.py
X =
 [[-0.9228375  -0.0725483   0.60156705]
 [ 0.40701538  1.31766102 -1.23749489]
 [ 0.40653825 -0.41175781  0.36202861]]
Inverse(X) =
 [[0.09401607 0.64023002 2.03222723]
 [1.88059997 1.67304528 2.59393312]
 [2.03334921 1.18391601 3.43037561]]

4, Prepare a sbatch script file, say test.sbatch for job submission, Remember to provide your partition name as appropriate or the job could not be executed.  Depending on your PI, you may access to different partitions and different GPU configuration. Please refer to here for more information.

#!/bin/bash
#SBATCH --job-name=test          # create a short name for your job
#SBATCH --nodes=1                # node count
#SBATCH --ntasks-per-node=1      # number of tasks per node (adjust when using MPI)
#SBATCH --cpus-per-task=1        # cpu-cores per task (>1 if multi-threaded tasks, adjust when using OMP)
#SBATCH --time=00:01:00          # total run time limit (D-HH:MM:SS)
#SBATCH --partition=intel        # partition(queue) where you submit (amd/intel/gpu-a30/gpu-l20)
#SBATCH --account=<account name> # slurm account name

python test.py

5. Submit your task using "sbatch" command

% sbatch --wait -o slurm.out test.sbatch

6. Check the result and the output should be similar to the above running manually.

% cat slurm.out
X =
 [[-0.9228375  -0.0725483   0.60156705]
 [ 0.40701538  1.31766102 -1.23749489]
 [ 0.40653825 -0.41175781  0.36202861]]
Inverse(X) =
 [[0.09401607 0.64023002 2.03222723]
 [1.88059997 1.67304528 2.59393312]
 [2.03334921 1.18391601 3.43037561]]

 

Learn More

Check out Slurm Partitions, QoS and Resource Limits for available resources could be used.