This page summarize some SLURM script example. If you do not want to read the SLURM offical Manual, you can just modify these examples for your script.
HOW-TO Submit a GPU Task
To use the GPU Server to run your GPU-base task is easy, you just need to apply for the GPU Compute Partition’s server, the partition name is: GPU-Compute-1.
ATTENTION, For now, in those GPU nodes, we only provide CUDA 10.
Here is an exmaple:
#!/bin/bash#SBATCH -J gpu-job # Task Name is: gpu-job#SBATCH -p GPU-Compute-1 # Submit task into `GPU-Compute` partition#SBATCH --gres=gpu:0 # Use one graphic card#SBATCH --cpus-per-task=8 # Apply 8 CPU cores#SBATCH -t 1-00:00:00 # Longest time is one daysource /home/user_name/anaconda-5.3.1 # load anaconda as the environment variablenvidia-smi
Tips
Although we are now using GPU to do the programming, we need CPU. This is the reason why we need CPUs’ allocated.
HOW-TO Submit a MATLB Task
We can submit our MATLAB tasks in two ways:
By Script [ Highly Recommoned ]
The exam script is:
#!/bin/bash
#SBATCH -J MATLAB-Task
#SBATCH -t 5:0:0 # Request 5 hourse runing time
#SBATCH -p CPU-Compute-1
source /home/user_name/environment/MATLAB
matlab -nodisplay -nosplash -nojvm -r file_name
As you can see, there are three parameters before the file_name , -nodisplay, -nosplash and -nojvm. These parameters can ensure that node runs the MATLAB code in CLI mode instead of GUI mode.
Also, to ensure every single core is not in a multi-thread mode, you can add -singleCompThread when you are sumbitting a parallel task. DO NOT USE parfor function
Tips
- Do not write
quitfunction in your MATLAB code, these would may cause the task release abnormally; - Usually, the MATLAB script’s name looks like:
file_name.m; to write a SLURM script, we ONLY needfile_name, no.m; - DO NOT use the
parforfunction inside the MATLAB code, this function would cause Redundancies abound problem
By GUI [ NOT Recommoned ]
Step One
Firstly, use salloc command to apply for computing node, for instance, I am now apply for a 1 node 4 core undate the CPU-Compute-1 Partition:
salloc -p CPU-Compute-1 -N 1 -n 4
Step Two
Use souce /home/user_name/environment/MATLAB to activate the MATLAB environment variable
Step Three
- Run CLI mode by:
matlab -nodisplay -nosplash -nojvm[no GUI mode is allowed in Computing nodes]
! Important you must enable GPU memory growth in your code
Insert the following code at the top of your code
For Tensorflow 1.x and Tensorflow 2.x
import tensorflow as tf
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
try:
# Currently, memory growth needs to be the same across GPUs
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
logical_gpus = tf.config.experimental.list_logical_devices('GPU')
print('----------START GPU----------')
print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs")
print('----------END GPU----------')
except RuntimeError as e:
# Memory growth must be set before GPUs have been initialized
print(e)
In order that all students can use GPU resources, if it is found that no GPU memory control code is added to all your codes, the administrator has the right to end the training task. Serious violators will be removed from the server
from [UIC-DS FYP Server Docs]
