Using Hopper
This page covers how to get onto Hopper, work on it comfortably, and run jobs. The overview covers what Hopper is and when it’s the right tool.
CAC’s rule is explicit: “Users should not run codes on the head node. Users who do so will be notified and have privileges revoked.”
Everyone on the cluster shares the head node. Editing files, moving data, and submitting jobs there is fine, but anything that computes belongs in a batch job or an interactive session. It’s easy to break this rule by accident when you work through a remote editor, so read the remote editing section before setting one up.
Getting an Account
You log in to Hopper with a CAC account, which is separate from your Cornell NetID. You get one by being added to the group’s CAC project; please message Vivek, since this should be part of onboarding.
Once your account exists:
ssh <your_cac_username>@hopper.cac.cornell.eduYou’ll be asked to set a new password the first time you log in. CAC passwords need at least eight characters drawn from at least three of uppercase letters, lowercase letters, digits, and symbols. They expire every six months, and you can reset them at passwordreset.cac.cornell.edu. Repeated failed logins lock the account for about thirty minutes.
CAC’s documentation doesn’t say whether either is required. If you’re off campus and SSH hangs, try the Cornell VPN before assuming your account is broken, and ask CAC if the problem continues.
SSH Keys
SSH keys are optional, but please set them up: they remove the password prompt, and remote editors need to log in without one.
On your own machine:
ssh-keygen -t ed25519 -C "hopper" # accept the defaults
ssh-copy-id <your_cac_username>@hopper.cac.cornell.eduThen add a host block to ~/.ssh/config so you can type ssh hopper:
~/.ssh/config
Host hopper
HostName hopper.cac.cornell.edu
User <your_cac_username>
IdentityFile ~/.ssh/id_ed25519
ServerAliveInterval 60
ServerAliveCountMax 10ServerAliveInterval stops idle connections from being dropped, which matters for long interactive sessions.
CAC also creates a key pair for you on the cluster itself. That key is for communication between nodes inside jobs (MPI and similar) and is unrelated to the key you use to log in.
Remote Editing
Editing files on Hopper from an editor on your laptop is much easier than editing in a terminal. All three options below use ordinary SSH.
VS Code and JetBrains both install a background server on the machine you connect to, and that server runs as you on the head node. Editing files that way is fine. Pressing Run or Debug in the editor is not, because it runs your analysis on the head node.
Use the editor to edit files and submit jobs. To run something interactively, start an interactive session in a terminal and work inside it.
Language servers and indexing extensions also use the head node’s CPU. If you point a Python or Julia extension at a large repository, it will index the repository on the head node, so keep your extensions to the ones you need. If you’re told you’re loading the head node, check this first.
CAC doesn’t document remote editors. The setups below work because Hopper supports standard SSH, and CAC hasn’t endorsed them.
VS Code
Install the Remote - SSH extension, run “Remote-SSH: Connect to Host”, and pick hopper (it reads the ~/.ssh/config block above). The first time you connect, VS Code installs its server into ~/.vscode-server, which takes a minute or two and uses some of your home-directory space.
JetBrains
JetBrains Gateway connects with the same SSH configuration and installs a full backend IDE under ~/.cache/JetBrains. That takes more space than the VS Code server, so if your home directory is nearly full, use VS Code.
Plain SSH
A terminal session needs nothing beyond SSH:
ssh hopper
tmux new -s work # or: tmux attach -t workWith tmux, a dropped connection doesn’t end what you were doing. Learn this even if you use an editor, because it’s what you fall back on when the editor’s server won’t start. The shell page has more.
Moving Files
For a few files, use rsync with your SSH configuration:
rsync -avP ./localdir/ hopper:~/remotedir/ # up
rsync -avP hopper:~/remotedir/ ./localdir/ # downFor large transfers, use Globus, which resumes interrupted transfers and checks that files arrived intact. Hopper’s collection is named Hopper Cluster.
Software and Environments
Modules
Hopper uses Lmod:
module avail # what is installed
module spider <name> # search, including modules not currently loadable
module load R/4.1.0 # case-sensitive
module list
module purge # start cleanLoad modules inside your job script as well as in your login shell, so the job doesn’t depend on your interactive environment.
Python
The conda page describes your own machine. On Hopper, CAC documents only venv and pip, there is no python3 module to load, and the system Python is version 3.6, which is old.
If your work needs a current Python, please talk to Vivek before spending time on this, since the setup from your laptop may not carry over. The options include building a newer Python yourself, using a Singularity container (module load singularity), or installing Miniforge in your home directory.
python3 -m venv ~/envs/myproject
source ~/envs/myproject/bin/activate
pip install --upgrade pip
pip install -r requirements.txtR
module load R
mkdir -p $R_LIBAfter that, install.packages('<name>') inside R installs packages into your home directory.
Julia
Julia is available as a module, but it may be an older version. Installing juliaup in your home directory lets you choose the version, which you’ll usually want for a project with a committed Manifest.toml.
Running Jobs
Hopper uses Slurm and has two partitions:
| Partition | Nodes | Time limit |
|---|---|---|
normal |
all | none |
guest |
all | 48 hours |
Hyperthreading is on, so Slurm treats each physical core as two CPUs: -n 1 gives you two logical CPUs, which is one physical core. Add --ntasks-per-core=1 if you want to ignore hyperthreading and count physical cores.
Batch Jobs
job.sh
#!/bin/bash
#SBATCH -J myjob # job name
#SBATCH -p normal # partition
#SBATCH -t 04:00:00 # walltime, hh:mm:ss
#SBATCH -n 1 # tasks
#SBATCH -c 8 # CPUs per task
#SBATCH -o logs/%x-%j.out # stdout (%x = name, %j = job id)
#SBATCH -e logs/%x-%j.err # stderr
#SBATCH --mail-type=END,FAIL
#SBATCH --mail-user=you@cornell.edu
module purge
module load gnu9
source ~/envs/myproject/bin/activate
python analysis.pyTo submit and monitor it:
mkdir -p logs # Slurm will not create it, and the job fails if it is missing
sbatch job.sh
squeue -u $USER
scancel <job_id>
scontrol show job <job_id>Always set -t to a realistic time. The normal partition has no limit, so a job that hangs will hold resources the rest of the cluster needs until someone cancels it.
Interactive Sessions
For debugging, exploratory work, or anything you would otherwise be tempted to run on the head node, start an interactive session:
srun -p normal -n 1 -c 8 --pty /bin/bash -lThis puts you on a compute node, where you can work normally. Type exit when you’re finished, since CAC asks that you release the allocation instead of leaving it idle.
Start the session from inside tmux on the head node, so that a dropped connection doesn’t end it.
CAC documents srun --pty but not salloc. salloc may work, but srun --pty is the documented way.
Job Arrays
Much of the group’s work is an ensemble of independent tasks (Monte Carlo replicates, parameter sweeps, one task per scenario), and a job array is the way to run it:
array.sh
#!/bin/bash
#SBATCH -J ensemble
#SBATCH -p normal
#SBATCH -t 02:00:00
#SBATCH -n 1
#SBATCH -c 4
#SBATCH --array=1-500%50 # 500 members, at most 50 running at once
#SBATCH -o logs/%x-%A_%a.out
module purge
source ~/envs/myproject/bin/activate
python run_member.py --member $SLURM_ARRAY_TASK_IDKeep the %50 limit, because it leaves capacity for the other three groups sharing the cluster. Each task reads its member number from $SLURM_ARRAY_TASK_ID; use it to set the random seed, to index into a parameter table, and to name the output file.
Chained and Dependent Jobs
When a workflow has stages (calibrate, then simulate, then post-process), submit them with dependencies so each stage starts when the previous one finishes:
jid1=$(sbatch --parsable calibrate.sh)
jid2=$(sbatch --parsable --dependency=afterok:$jid1 simulate.sh)
sbatch --dependency=afterok:$jid2 postprocess.shWith afterok, a job runs only if the previous job succeeded. To wait for an entire array, use --dependency=afterok:$jid with the array’s job ID; the dependent job starts once every task has finished.
Staging Data Through /tmp
Home directories are on NFS, shared across all nodes, so heavy reading and writing from many tasks at once slows the file system for everyone. CAC says: “We cannot stress enough how important this is to avoid delays on the file systems.”
If your job does heavy file I/O, copy inputs to the node’s local /tmp first, work there, and copy results back at the end:
MYTMP=/tmp/$USER/$SLURM_JOB_ID
mkdir -p $MYTMP || exit 1
cp -rp $SLURM_SUBMIT_DIR/inputs $MYTMP/ || exit 1
cd $MYTMP && python analysis.py
cp -rp $MYTMP/output $SLURM_SUBMIT_DIR/ || exit 1
rm -rf $MYTMPThis is most important for job arrays, where the load grows with the number of tasks running at once.
FAQ
Why is my job stuck in PENDING?
squeue -u $USER shows the reason. Resources means the cluster is busy, which is normal; wait. Priority means other jobs are queued ahead of yours. PartitionTimeLimit means your -t is longer than the partition allows. If a job has been pending for days, please ask before resubmitting it.
Why is my job slower than on my laptop?
There are two common causes. Hopper’s Intel cores run at 2.1 GHz, well below a typical workstation, so serial code really is slower there (see when to use Hopper). Or your job spends its time reading and writing files on NFS, in which case stage the data through /tmp.
How do I get more memory?
The AMD nodes (c0023-c0026) have 567 GB of memory, against 192 GB on the Intel nodes. Request memory with --mem= or --mem-per-cpu=, or ask for the large nodes with -w.
How do I see what a finished job used?
Try sacct -j <job_id> or seff <job_id>. These are standard Slurm tools, but CAC’s documentation doesn’t mention them, so they may not be set up on Hopper. Please try them and tell the rest of us whether they work.
I ran out of space in my home directory. What now?
Check with du -sh ~/*. Editor servers, conda environments, and old job output often take the most space. Remember that nothing on Hopper is backed up; Data Management explains where data should go instead.
Is there a web interface?
No. CAC’s Open OnDemand portal is for the Seneca cluster, and Hopper is reached only through SSH.
Something is broken, and it isn’t my code. Who do I tell?
Check portal.cac.cornell.edu/status, then email help@cac.cornell.edu with “Hopper” in the subject line. Please tell Vivek too, since it probably affects the rest of the group.
More Information
- CAC TechDocs: Hopper, the authoritative reference
- Slurm and Slurm Quick Start from CAC
slurm_tutorial, the group’s example submission scripts in Julia and Pythoncluster-training, older HPC training materials- Water Programming on HPC and Slurm