with a focus on using the SWC’s HPC cluster.


(Correct at time of writing)
Log into bastion node (not necessary within SWC network)
This node should only be used for navigating the file system, submitting jobs or editing scripts with a terminal text editor (e.g. nano or vim)
More details
See our guide at https://neuroinformatics.dev/howto/
/nfs/nhome/live/<USERNAME> or /nfs/ghome/live/<USERNAME>
~//nfs/winstor/<group> - Old SWC research data storage/nfs/gatsbystor - GCNU data storage/ceph/<group> - Current research data storage/ceph/scratch - Not backed up, for short-term storage/ceph/apps - HPC applicationsNote
You may only be able to “see” a drive if you navigate to it
Navigate to the scratch space
pwd and cd: Navigate Directoriescd [directory] – Changes the current working directory to the specified directory.cd .. – Move up one directory level.cd /path/to/directory – Go to a specific path.cd ~ or cd – Go to the home directory.cd / – Go to the root directory.pwd – Prints the current working directory.ls: List Directory Contentsls – Lists files and directories in the current working directory.ls -l – Displays detailed information about each file (permissions, owner, size, etc.).ls -a – Shows all files, including hidden files (files starting with a dot).ls -h – Displays sizes in human-readable format (e.g., KB, MB).ls -lah – Combines the above options.mkdir: Make Directorymkdir [directory_name] – Creates a new directory with the specified name.mkdir -p /path/to/dir to create nested directories.rmdir and rm: Remove Directories and Filesrm [file]– Removes a file.rmdir [directory] – Removes an empty directory.rm -r [directory] - Removes a directory and its contents recursively.rm -f [file] - Removes to force remove a file (no undo be careful!).mv and cp: Move, Rename and Copycp [source] [destination] – Copies a file or directory to the destination.mv [source] [destination] – Moves a file or directory to the destination.mv can also be used to rename a file or directory if the source and destination directories match.echo [text] – Displays text or outputs text to a file.echo $ENV_VAR – Displays the value of an environment variable.touch [filename] – Creates an empty file or updates the timestamp of an existing file.> – Redirects output to a file.>> – Appends output to a file.cat [file] – Displays the contents of a file.less [file] – Opens a file in a scrollable viewer, allowing navigationnano [file] – Opens a file in the nano text editor for editingchmod [permissions] [file] – Changes the permissions of a file or directorychmod 755 file.txt sets permissions to rwxr-xr-x (user has read, write, execute; group and others have read and execute)r for read, w for write, and x for executeu for user, g for group, and o for others (if skipped it applies to all)chmod u+x file.txt adds execute permission for the userchmod go-w file.txt removes write permission for group and otherswatch: Monitor Command Outputwatch [command] – Repeatedly runs a command at intervals and displays the result.watch -n [seconds] [command] to change the interval.man [command] – Opens the manual page for a command.help [command] – Provides a short description of built-in commands.|: Pipes!Description:
| – Pipes the output of one command as input to another.All nodes have the same software installed
Preinstalled packages available for use, including:
List available modules
View a summary of the available resources
sirmpilatzen@hpc-gw2:~$ sinfo
PARTITION AVAIL TIMELIMIT NODES STATE NODELIST
cpu* up 10-00:00:0 1 down* enc1-node4
cpu* up 10-00:00:0 10 mix enc1-node[1-3,6,8-13]
cpu* up 10-00:00:0 2 alloc enc1-node[5,7]
a100 up 10-00:00:0 4 mix gpu-sr670-[20-23]
gpu up 10-00:00:0 18 mix gpu-350-[01,03-05],gpu-380-[10-18],gpu-sr670-[20-23],gpu-sr675-31
gpu up 10-00:00:0 1 idle gpu-350-02
gpu_lowp up 10-00:00:0 6 mix gpu-sr675-[31-35],gpu-xd670-30
cpu_backfill up 10-00:00:0 23 mix gpu-350-[01,03-05],gpu-380-[10-18],gpu-sr670-[20-23],gpu-sr675-[31-35],gpu-xd670-30
cpu_backfill up 10-00:00:0 1 idle gpu-350-02
View currently running jobs, from everyone…
sirmpilatzen@hpc-gw2:~$ squeue
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
3705995 a100 nette-rp kbiegun R 1:45:06 1 gpu-sr670-20
3705996 a100 nette-rp kbiegun R 1:45:06 1 gpu-sr670-20
3700888_2 a100 human_ta mmeyer R 23:20:39 1 gpu-sr670-21
3403594 cpu shrink_r wdorrell PD 0:00 1 (DependencyNeverSatisfied)
3664831_[154,156,2 cpu r50_clas isebti PD 0:00 1 (JobArrayTaskLimit)
3704854_[9-29%6] cpu dt_signa larsr PD 0:00 1 (JobArrayTaskLimit)
3705838_[73-79,81- cpu b2lameps eling PD 0:00 1 (Resources)
3014724 cpu modelbui careyh PD 0:00 1 (Dependency)
Think of them as logical queues. Three types:
cpu, gpu, a100gpu_saxe, gpu_brancocpu_backfill, gpu_lowpMore details on SWC/GCNU Scientific Computing wiki
Warning
To spare the gateway node, always start a job (interactive or batch) before doing anything beyond simple filesystem navigation or terminal-based script editing.
Start an interactive job (bash -i) in the cpu partition (-p cpu) in pseudoterminal mode (--pty) with one CPU core (-n 1).
Tip
If the cpu partition is busy, you can cancel the request with Ctrl+C and try -p cpu_backfill instead.
Clone some example scripts
Check out batch script
#!/bin/bash
#SBATCH -p cpu # partition (queue)
#SBATCH -N 1 # number of nodes
#SBATCH --mem 1G # memory pool for all cores
#SBATCH -n 1 # number of cores
#SBATCH -t 0-0:1 # time (D-HH:MM)
#SBATCH -o slurm_output.out
#SBATCH -e slurm_error.err
# Exit immediately if any command fails
set -e
for i in {1..5}
do
./multiply.sh $i 10
doneRun batch job
More details
See our SLURM arguments primer
Check out array script
#!/bin/bash
#SBATCH -p cpu # partition (queue)
#SBATCH -N 1 # number of nodes
#SBATCH --mem 1G # memory pool for all cores
#SBATCH -n 1 # number of cores
#SBATCH -t 0-0:1 # time (D-HH:MM)
#SBATCH -o slurm_array_%A-%a.out
#SBATCH -e slurm_array_%A-%a.err
#SBATCH --array=0-9%4
# Exit immediately if any command fails
set -e
# Array job runs 10 separate jobs, but not more than four at a time.
# This is flexible and the array ID ($SLURM_ARRAY_TASK_ID) can be used in any way.
echo "Multiplying $SLURM_ARRAY_TASK_ID by 10"
./multiply.sh $SLURM_ARRAY_TASK_ID 10 Run array job
Cancel a job
Tip
You can find the job ID with squeue --me.
So far, we’ve been running bash scripts, but you can also run Python code in the same way.
Exit the Python session with exit() , then exit the interactive job with exit.
As an exercise, do the exact same thing with a batch job.
nano to create a Python script called hello.py and add a line printing “Hello HPC world!” to it.hello_batch.sh that runs the Python script.Tip
Want to create and use your own Python environments? Stay tuned, this is described towards the end of this course.
HPC jobs use energy (and emit carbon) whether or not they produce anything useful.
set -e in bash batch scripts)scancel <JOBID>)sbatch --beginSee also SWC/GCNU Scientific Computing wiki
After a job finishes, compare what it used with what you requested:
MaxRSS much lower than ReqMem? Request less memory next timeElapsed much shorter than Timelimit? Request less timeLet’s look at a real-world example. Learning goals:

More details
We maintain the following resources for SLEAP users:
/ceph/scratch/neuroinformatics-dropoff/SLEAP_HPC_test_data/CalMS21
More details
See animals-in-motion.neuroinformatics.dev/latest/prerequisites for more information about the data.


Copy the unzipped training package to your scratch space and inspect its contents:
centroid.json
inference-script.sh
jobs.yaml
mouse044_task1_annotator1.train.pkg.pkg.slp
multi_class_topdown.json
train-script.sh
Training
#!/bin/bash
sleap-train centroid.json mouse044_task1_annotator1.train.pkg.pkg.slp
sleap-train multi_class_topdown.json mouse044_task1_annotator1.train.pkg.pkg.slp
Suitable for debugging (immediate feedback)
Start an interactive job with one GPU
Execute commands one-by-one, e.g.:
sleap_train_slurm.sh
#!/bin/bash
#SBATCH -J slp_train # job name
#SBATCH -p gpu # partition (queue)
#SBATCH -N 1 # number of nodes
#SBATCH --mem 32G # memory pool for all cores
#SBATCH --ntasks-per-node=1 # one process per node
#SBATCH --cpus-per-task=8 # CPU cores available to the process
#SBATCH -t 0-06:00 # time (D-HH:MM)
#SBATCH --gres gpu:a100:1 # request 1 GPU of a given type (see dropdown below)
#SBATCH -o slurm.%x.%N.%j.out # STDOUT
#SBATCH -e slurm.%x.%N.%j.err # STDERR
#SBATCH --mail-type=ALL
#SBATCH --mail-user=user@domain.com
# Exit immediately if any command fails
set -e
# print GPU info
nvidia-smi
# Load the SLEAP module
module load SLEAP
# Define the directory of the exported training job package
SLP_JOB_NAME=mouse044_task1_annotator1.training_job
SLP_JOB_DIR=/ceph/scratch/$USER/$SLP_JOB_NAME
# Go to the job directory
cd $SLP_JOB_DIR
# Run the training script generated by SLEAP
./train-script.sh--gres gpu:a100:1 requests 1 GPU of type A100.--gres gpu:1 requests 1 GPU of any typeInspect available GPU types by listing the nodes in the gpu and gpu_lowp partitions:
Look for the string between the two colons: that’s what you need for --gres
Warning
Avoid GPUs with CUDA compute capability below 7.5 (unsupported by PyTorch ≥ 2.5); at the time of writing, only p5000 cards are incompatible.
See the SWC wiki and the NVIDIA CUDA GPUs page for compute capabilities.
View the status of your queued/running jobs with squeue --me
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
3750192 gpu slp_trai nstest R 3:47 1 gpu-sr670-20
View status of running/completed jobs with sacct:
JobID JobName Partition Account AllocCPUS State ExitCode
------------ ---------- ---------- ---------- ---------- ---------- --------
4232289 slp_train gpu swc-ac 4 RUNNING 0:0
4232289.bat+ batch swc-ac 4 RUNNING 0:0
Run sacct with some more helpful arguments, e.g. view jobs from the last 24 hours, incl. time elapsed and peak memory usage in KB (MaxRSS):
Until now, we have used preinstalled modules.
But more realistically, you’ll want to run your own code. In Neuroscience the most popular language is Python.
Goal: run a Python script on the HPC.
numpy, pandas, scikit-learn.uv (alternative to conda, poetry, mamba, …).Let’s create a Python project locally:
Install uv: https://docs.astral.sh/uv/getting-started/installation/
Create a directory called spike_times_analysis
Open the directory in the terminal and check you’re in the right place
uv has created a bunch of files. pyproject.toml is a description of your project, including which packages you’ve included. The most important list is the dependencies.
uv add ?? and check your pyproject.toml.If you give this pyproject.toml file to a friend, they’ll be able to (approximately) remake your environment.
Let’s write some code. I’ll save it at spike_times_analysis/scripts/analyse_spikes.py
And try to run it
uv runuv run ?? does the following sequence of events:
pyproject.toml and figures out which packages and package versions you need.venvpython ??Let’s do the same thing, but now on the HPC
spike_sort_pipelineuv is a module on the HPC. Load it.uvCreate a test Python script in spike_sort_pipeline/test.py
And run it
By default, uv saves your environment in your project folder.
It also keeps a cache so that if you use the same package in several projects, it can “share” it.
This is usually fine.
But on the HPC there are many physical drives “stuck together” to look like the ceph. It’s a good idea to insist that uv uses a cache and environment location on the same physical storage.
We can do this by setting the UV_PROJECT_ENVIRONMENT variable, as we’ll see.
The real power of the HPC comes when we can submit jobs to run scripts. Let’s create a bash script called test.sh containing
#!/bin/bash
#SBATCH -p cpu
#SBATCH -N 1
#SBATCH --mem 1G
#SBATCH -n 1
#SBATCH -t 0-0:1
#SBATCH -o test_output.out
#SBATCH -e test_error.err
set -e
module load uv
export UV_PROJECT_ENVIRONMENT="/ceph/python_envs/YOURUSERNAME/spike_sort_pipeline"
cd /ceph/scratch/YOURUSERNAME/spike_sort_pipeline/
uv run test.pyand submit it
We’re going to use a GPU to spike sort a Neuropixels recording using SpikeInterface and Kilosort.
First, let’s add both these packages to the spike_sort_pipeline project
and check they are there
Make a spike sorting file at spike_sort_pipeline/spike_sort.py
import spikeinterface.full as si
recording = si.read_openephys('/ceph/scratch/neuroinformatics-dropoff/neuropixel2_data')
recording_one_shank = recording.split_by('group')[0]
sorting = si.run_sorter('kilosort4', recording_one_shank, remove_existing_folder=True, use_binary_file=False, verbose=True)
analyzer = si.create_sorting_analyzer(
sorting=sorting,
recording=si.bandpass_filter(si.common_reference(recording_one_shank)),
folder = 'kilosort4_sorting_analyzer',
format='binary_folder'
)
analyzer.compute(['random_spikes', 'templates', 'unit_locations', 'correlograms', 'spike_amplitudes', 'spike_locations', 'quality_metrics'])(You can find this file at /ceph/scratch/neuroinformatics-dropoff/spike_sort.py)
And run it (just to test)
Make a bash script called spike_sort.sh:
#!/bin/bash
#SBATCH -J spike_sort
#SBATCH -p gpu
#SBATCH --gres=gpu:1
#SBATCH -N 1
#SBATCH --mem 32G
#SBATCH -n 8
#SBATCH -t 0-1:0
#SBATCH -o spike_sort_%j.out
#SBATCH -e spike_sort_%j.err
set -e
module load uv
export UV_PROJECT_ENVIRONMENT="/ceph/python_envs/YOURUSERNAME/spike_sort_pipeline"
cd /ceph/scratch/YOURUSERNAME/spike_sort_pipeline/
uv run spike_sort.pyand submit it
This script creates a SortingAnalyzer. This is the “end point” of a SpikeInterface spike sorting pipeline. You can take a look at the results using SpikeInterface-GUI.

SWC | October 2026