Check out the excellent Python framework Ray Tune here. A script for using Ray with Slurm is at ./ray_with_slurm. Take a look at the slurm_launch.py command line ...
Create the compute nodes (slurm-node1 and slurm-node2). multipass launch --name slurm-node1 --cpus 1 --mem 2G --disk 10G multipass launch --name slurm-node2 --cpus 2 --mem 4G --disk 10G On ...