Commit fead3904 authored by Eamonn Martin's avatar Eamonn Martin
Browse files

Initial commit

parents
Pipeline #1938 failed with stages
# Slurm
Slurm is a workload manager, it runs on: `slurm.doc.gold.ac.uk`. Slurm
can be accessed via ssh using your usual college credentials – the
same as for igor.
To run your code on a GPU compute node you first need to copy all of
your code to your DOC shared home directory and then submit it as a
job to Slurm.
For example, to run this demo, ssh into `slurm.doc.gold.ac.uk` and
clone this repository.
``` sh
ssh <user>@slurm.doc.gold.ac.uk
git clone https://gitlab.doc.gold.ac.uk/slurm/mnist-slurm-demo.git
cd mnist-slurm-demo
sbatch mnist-job.sh # This command submits the job.
```
Slurm will schedule your job immediately when resources become
available.
## Example batch script
``` sh
#!/bin/sh
#SBATCH --time 4 # time in minutes to reserve
#SBATCH --cpus-per-task 2 # number of cpu cores
#SBATCH --mem 4G # memory pool for all cores
#SBATCH --gres gpu:1 # number of gpu cores
#SBATCH -o mnist.log # write output to log file
# Run jobs using the srun command.
srun -l python mnist.py
```
# Useful commands
See the [documentation](https://slurm.schedmd.com) for more
information.
## Submitting jobs
``` sh
sbatch mnist-job.sh
```
## Show information about a running job
Replace `<n>` below with your job id.
``` sh
sstat <n>
```
## Show information about all submitted jobs
``` sh
sacct
```
## Show specific information about a job
``` sh
sacct --units G --format=jobid,avecpu,alloccpus,avevmsize -j <n>
```
#!/bin/sh
#SBATCH --time 4 # time in minutes to reserve
#SBATCH --cpus-per-task 2 # number of cpu cores
#SBATCH --mem 4G # memory pool for all cores
#SBATCH --gres gpu:1 # number of gpu cores
#SBATCH -o mnist.log # write output to log file
# Run jobs using the srun command.
srun -l python mnist.py
import tensorflow as tf
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(512, activation=tf.nn.relu),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(x_train, y_train, epochs=5)
print('Evaluation:', model.evaluate(x_test, y_test))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment