@@ -192,16 +192,19 @@ where the animal occupies a relatively small portion of the frame - see
192192:::
193193
194194SLEAP also generates a ` train-script.sh ` file in the training job folder.
195- You can inspect it with ` cat train-script.sh ` to see the training commands it contains —
196- these are useful as a reference, but they reflect the paths on the machine that
197- exported the training job package and may not work as-is on the HPC cluster.
198- Instead, we'll write the ` sleap train ` commands from scratch in the next step.
195+ You can inspect it with ` cat train-script.sh ` to see the training commands it contains.
196+ These are useful as a reference, but be cautious about copying them verbatim.
197+ They may point to folders on the machine that exported the training package,
198+ rather than on the cluster. They may also include a ` trainer_config.run_name=... `
199+ setting whose value contains an ` = ` sign. This makes SLEAP stop with an error like
200+ ` mismatched input '=' expecting ` . Instead, we'll write the ` sleap train ` commands from
201+ scratch in the next step, letting SLEAP name each training run automatically.
199202
200203Next you need to create a SLURM batch script, which will schedule the training job
201- on the HPC cluster. Create a new file called ` train-slurm.sh `
202- (you can do this in the terminal with ` nano ` / ` vim ` or in a text editor of
203- your choice on your local PC/laptop). Here we create the script in the same folder
204- as the training job, but you can save it anywhere you want, or even keep track of it with ` git ` .
204+ on the HPC cluster. Create a new file called ` train-slurm.sh ` inside the training job
205+ folder (the same folder that holds the config files), because the training commands
206+ below use paths relative to that folder. You can create it in the terminal with
207+ ` nano ` / ` vim ` , or write it in a text editor on your local machine and copy it in .
205208
206209``` {code-block} console
207210$ nano train-slurm.sh
@@ -231,17 +234,9 @@ nvidia-smi
231234# Load the SLEAP module
232235module load SLEAP
233236
234- # Define directories for SLEAP project and exported training job
235- SLP_DIR=/ceph/scratch/neuroinformatics-dropoff/SLEAP_HPC_test_data
236- SLP_JOB_NAME=labels.v002.slp.training_job
237- SLP_JOB_DIR=$SLP_DIR/$SLP_JOB_NAME
238-
239- # Go to the job directory
240- cd $SLP_JOB_DIR
241-
242237# Run the training for each model
243- sleap train --config-name centroid.yaml --config-dir . trainer_config.ckpt_dir="$SLP_DIR/ models"
244- sleap train --config-name centered_instance.yaml --config-dir . trainer_config.ckpt_dir="$SLP_DIR/ models"
238+ sleap train --config-name centroid.yaml --config-dir . trainer_config.ckpt_dir=' models'
239+ sleap train --config-name centered_instance.yaml --config-dir . trainer_config.ckpt_dir=' models'
245240```
246241
247242:::{dropdown} Explanation of the batch script
@@ -269,28 +264,21 @@ sleap train --config-name centered_instance.yaml --config-dir . trainer_config.c
269264- `module load SLEAP` loads the latest SLEAP module and its dependencies.
270265 PyTorch bundles its own CUDA runtime, so no separate `cuda` module is needed.
271266
272- - `cd $SLP_JOB_DIR` is needed because ` --config-dir .` in the `sleap train` commands
273- uses a relative path to find the YAML configuration files .
267+ - `--config-dir .` and `trainer_config.ckpt_dir='models'` use paths relative to the
268+ training job folder, so submit the script from within that folder (see below) .
274269
275270- Each `sleap train` call trains one model: `--config-name` selects the YAML file,
276- `--config-dir` the directory containing it, and `trainer_config.ckpt_dir`
277- sets where the trained model files will be saved.
271+ `--config-dir .` points to the current folder containing it, and
272+ `trainer_config.ckpt_dir='models'` saves the trained model into a `models/`
273+ subfolder of the training job folder.
278274:::
279275
280276Using a legacy (TensorFlow) module instead? See [Legacy (TensorFlow) modules](legacy-modules) for the equivalent training commands.
281277
282- :::{warning}
283- Before submitting the job, ensure that you have permissions to execute
284- the SLURM batch script. You can make it executable by running:
285-
286- ```{code-block} console
287- $ chmod +x train-slurm.sh
288- ```
289- :::
290-
291- Now you can submit the batch script via running the following command
292- (in the same directory as the script):
278+ Now submit the batch script from within the training job folder, so that the
279+ relative paths in the script resolve correctly:
293280```{code-block} console
281+ $ cd /ceph/scratch/neuroinformatics-dropoff/SLEAP_HPC_test_data/labels.v002.slp.training_job
294282$ sbatch train-slurm.sh
295283Submitted batch job 3445652
296284```
@@ -366,11 +354,11 @@ If you encounter out-of-memory errors, keep in mind that there are two main sour
366354(model-evaluation)=
367355## Model evaluation
368356Upon successful completion of the training job, a ` models ` folder will have
369- been created in your specified ` trainer_config.ckpt_dir ` .
357+ been created inside the training job folder (as set by ` trainer_config.ckpt_dir='models' ` ) .
370358It contains one subfolder per training run.
371359
372360``` {code-block} console
373- $ cd /ceph/scratch/neuroinformatics-dropoff/SLEAP_HPC_test_data
361+ $ cd /ceph/scratch/neuroinformatics-dropoff/SLEAP_HPC_test_data/labels.v002.slp.training_job
374362$ cd models
375363$ ls -1
376364'260512_151547.centroid.n=46'
@@ -442,8 +430,8 @@ mkdir -p $SLP_DIR/predictions
442430# Run the inference command
443431sleap track \
444432 -i $SLP_DIR/mice.mp4 \
445- -m $SLP_DIR/models/260512_151547.centroid.n=46 \
446- -m $SLP_DIR/models/260512_151547.centered_instance.n=46 \
433+ -m $SLP_DIR/labels.v002.slp.training_job/ models/260512_151547.centroid.n=46 \
434+ -m $SLP_DIR/labels.v002.slp.training_job/ models/260512_151547.centered_instance.n=46 \
447435 -d auto \
448436 -b 4 \
449437 --tracking \
0 commit comments