Cluster Tool sends SLURM jobs to more than one cluster. You run it on one computer, for
example a laptop. ct gets the names of your clusters from ~/.ssh/config. It keeps no
list of hosts of its own.
An AI model (Claude) wrote all of this code. There are no tests. Test each command before
you use it for important work. The -n option shows the actions but does not do them.
ct reads ~/.ssh/config and uses the Host names that it finds there. For example:
Host hpc1
HostName login.example.org
User myaccount
ForwardAgent yes
Host gpu1
HostName gpu.example.org
User myaccount
ForwardAgent yes
Host ws
HostName workstation.example.orgWith this file you write hpc1, gpu1 and ws in every ct command. ct ignores a
pattern such as Host *, and it also ignores an Include line.
ct starts the ssh program for each connection. Therefore ssh reads your keys and your
certificates, and ct never reads them. Keep ForwardAgent yes for each cluster: this
setting lets the cluster read your git remote.
Your computer and each cluster hold a clone of your git repository. ct connects with
ssh, runs git pull on the cluster, then runs sbatch.
A cluster runs only the code that is on the git remote. ct does not copy files from your
computer. Therefore you must push your work first.
You need Python 3.9 or later, and the ssh and git programs.
pip install -e .Or use uv tool install --editable ..
Run this command one time:
ct initct shows the Host names from ~/.ssh/config. Select the SLURM clusters, then select the
workstations. ct writes your selection to ~/.config/ct/config.toml. Run the command
again to change it.
Then run this command in a git repository:
ct init .ct finds the clusters for this project. It finds or makes the clone on each cluster. It
writes .ct.toml and adds the name to .gitignore.
myproject/
.ct.toml # ct makes this file
slurm/
hpc1/ train.sbatch sweep_lr.sbatch
gpu1/ train_2gpu.sbatch
src/
A directory in slurm/ must have the ssh name of a cluster. Such a directory makes the
cluster a target. ct shows only the files that end with .sbatch.
ct starts each job from the top directory of the repository. Therefore the relative paths
in your sbatch files are correct on every cluster. Put the settings that change from cluster
to cluster in the directory of that cluster, for example the partition and the account.
git pushct run allct run all runs git pull on each cluster, finds the sbatch files that are new, shows
them, and then starts the files that you select.
ct keeps a record of the contents of each sbatch file. If you change a file, ct shows it
again with the label changed. If you select a subset, ct marks the other files
skipped and does not show them again. Use ct seen --forget PATH to show a file again.
| Command | Function |
|---|---|
ct run all |
Start all of the new sbatch files |
ct run hpc1 |
Select the files on one cluster |
ct new |
Show the new files. Start nothing |
ct st |
Show your jobs on all clusters |
ct st hpc1 gpu1 |
Show your jobs on some of the clusters |
ct st all |
Show the jobs of all users |
ct st all hpc1 |
Show the jobs of all users on one cluster |
ct st -w |
Show your jobs. Refresh every 5 seconds |
ct st -a |
Also show your jobs that stopped |
ct free |
Show the partitions, the nodes and the GPUs |
ct log hpc1:4821 |
Show the output of a job. Add -f to follow it |
ct kill hpc1:4821 |
Stop one or more jobs |
ct sync |
Run git pull on the clusters. Start nothing |
ct push |
Commit and push this clone |
ct pull |
Update this clone from the git remote |
ct sh hpc1 |
Open a shell on a host |
ct sh hpc1 -- nvidia-smi |
Run one command on a host |
ct targets |
Show the status of each host |
ct seen |
Show the record of the sbatch files |
The -y option answers the questions. -y never pushes your work.
Run ct --help for these forms, or ct <command> --help for one command.
ct shows a job as hpc1:4821. Use this name with ct log and ct kill. You can also
write ct kill hpc1 4821, which works for a job that ct did not start. You can write only
the number, but ct shows an error if two clusters use that number.
- On a cluster,
ctusesgit merge --ff-only.ctdoes not start a job if the cluster is not at the same commit as the git remote. ctusessqueue -u $(whoami), which also works with SLURM 19.05.- Set
CT_SSH=echoto print the remote commands without running them. .ct.tomlholds the path of the repository on each cluster. Such a path usually contains your account name, soctkeeps the file out of git.ctchecks this rule again before eachct push. If the file is already in git,ctstops and tells you what to do.ct pushrunsgit add -A, so it commits every new file in your directory. Checkgit statusfirst if you keep data files or secrets there.