Linux and department servers: Difference between revisions

From Stat DS Computing Wiki
Mention Leviathans
Line 1: Line 1:


The department has a set of servers, the hydras, that can help you run large analyses and gain a better understanding of common command line structure for more high scale computing. One can also view the department servers a bit more as a “sandbox” or “playground” as there are very few constraints and it’s okay to not run as polished code as you might on the [[PSC]] or Azure.
The department has two sets of servers, the Leviathans and the Hydras, that can help you run large analyses and gain a better understanding of common command line structure for more high scale computing. One can also view the department servers a bit more as a “sandbox” or “playground” as there are very few constraints and it’s okay to not run as polished code as you might on the [[PSC]] or Azure.


['''Request:''' Windows users (and all users) - if you see comments that are outdated / less helpful than expected please contribute.]
['''Request:''' Windows users (and all users) - if you see comments that are outdated / less helpful than expected please contribute.]
Line 6: Line 6:
== What resources exist ==
== What resources exist ==


# The department provides 13 servers (named {<code>hydra1</code>, ... , <code>hydra13</code>}<code>.stat.cmu.edu</code>.  
# The department provides 13 hydra servers (named {<code>hydra1</code>, ... , <code>hydra13</code>}<code>.stat.cmu.edu</code> and 6 leviathan servers (named {<code>leviathan1</code>, ..., <code>leviathan6</code>}<code>.stat.cmu.edu</code>)
# Each hydra has 12 CPU cores, and 64 GB of RAM (per core).
# Each Hydra has 12 CPU cores and 64 GB of RAM.
## The exceptions are hydra7 and hydra8, which have 128 GB of RAM. Use these if you have particularly large jobs that need lots of memory.
## The exceptions are hydra7 and hydra8, which have 128 GB of RAM. Use these if you have particularly large jobs that need lots of memory.
# The hydras all share the same data file system. This allows you to upload a file to any of the hydras and then have it on all of them.
# Each Leviathan has 16 CPU cores and 128 GB of RAM. The Leviathan CPUs are much faster than the Hydra CPUs.
# The Hydras and Leviathans all share the same data file system. This allows you to upload a file to any of the servers and then have it on all of them.
# [[OpenMPI]] is installed
# [[OpenMPI]] is installed
#* This allows MPI based parallelization to be used
#* This allows MPI based parallelization to be used
Line 27: Line 28:


=== Checking current usage ===
=== Checking current usage ===
To check which servers are currently being used and which are open, see the [https://info.stat.cmu.edu/grafana/d/fdkb6l4klj400d/hydra-cluster?orgId=1 Grafana dashboard for the hydras]. It lists them all and their current usage.
To check which servers are currently being used and which are open, see the [https://info.stat.cmu.edu/grafana/d/beuw1q6y3dgjkc/hydra-cluster?orgId=1 Grafana dashboard for the hydras] and [https://info.stat.cmu.edu/grafana/d/asjkldfbnvajdsfh213/leviathan-cluster?orgId=1 for the Leviathans]. It lists them all and their current usage.


When you're logged in to one node, you can use the <code>top</code> command. <code>top</code> displays the current usage of the server’s resources with a list of jobs run. It also tells you the percentage of the cores that are being used and the amount of RAM (memory) that is available. See [https://www.howtogeek.com/668986/how-to-use-the-linux-top-command-and-understand-its-output/ howtogeek] resources on how to interpret it all (the documentation is very clean, so we encourage you to read up ther
When you're logged in to one node, you can use the <code>top</code> command. <code>top</code> displays the current usage of the server’s resources with a list of jobs run. It also tells you the percentage of the cores that are being used and the amount of RAM (memory) that is available. See [https://www.howtogeek.com/668986/how-to-use-the-linux-top-command-and-understand-its-output/ howtogeek] resources on how to interpret it all (the documentation is very clean, so we encourage you to read up ther

Revision as of 15:07, 24 October 2025

The department has two sets of servers, the Leviathans and the Hydras, that can help you run large analyses and gain a better understanding of common command line structure for more high scale computing. One can also view the department servers a bit more as a “sandbox” or “playground” as there are very few constraints and it’s okay to not run as polished code as you might on the PSC or Azure.

[Request: Windows users (and all users) - if you see comments that are outdated / less helpful than expected please contribute.]

What resources exist

  1. The department provides 13 hydra servers (named {hydra1, ... , hydra13}.stat.cmu.edu and 6 leviathan servers (named {leviathan1, ..., leviathan6}.stat.cmu.edu)
  2. Each Hydra has 12 CPU cores and 64 GB of RAM.
    1. The exceptions are hydra7 and hydra8, which have 128 GB of RAM. Use these if you have particularly large jobs that need lots of memory.
  3. Each Leviathan has 16 CPU cores and 128 GB of RAM. The Leviathan CPUs are much faster than the Hydra CPUs.
  4. The Hydras and Leviathans all share the same data file system. This allows you to upload a file to any of the servers and then have it on all of them.
  5. OpenMPI is installed
    • This allows MPI based parallelization to be used
    • Note that the hydras ARE NOT network connected, so MPI can only be used within a single hydra. It cannot communicate across multiple hydras.
    • If you need to run something in parallel across multiple nodes, you should use PSC instead.

See What resources when for guides to help decide which resource you should be using.

Using the servers respectfully

Because the servers are a shared department resource it is important to use them respectfully. There are many servers and multiple cores (CPUs) per server. To be respectful of other users:

  1. Check the current usage of the server you're on before using it.
  2. Do not use all the cores on a server, and do not use all the servers at the same time, so others can get work done.
  3. If you have a long-running job, deprioritize it so others can run too.

Each of these is easy to check.

Checking current usage

To check which servers are currently being used and which are open, see the Grafana dashboard for the hydras and for the Leviathans. It lists them all and their current usage.

When you're logged in to one node, you can use the top command. top displays the current usage of the server’s resources with a list of jobs run. It also tells you the percentage of the cores that are being used and the amount of RAM (memory) that is available. See howtogeek resources on how to interpret it all (the documentation is very clean, so we encourage you to read up ther

Limiting the cores you use

We recommend that when using parallel processing, use fewer than the total number of cores on the server. Most parallel processing packages let you choose the number of cores to use; the hydras have 12, so pick something smaller.

Deprioritize when possible

nice/renice allows you to lower the priority of your jobs, so the operating system lets other processes run first. See howtogeek resources on the basics. nice sets the priority, and renice updates your priority. On the department servers, everyone starts at the same priority, and you can only deprioritize your jobs -- you can't make them higher priority than everyone else.

nice -20 Rscript some-big-script.R
renice -n 20 processid # get the process ID from top

Introduction to connecting to the server and useful Linux commands

The department servers all run Linux, and require you to use a command line to interact with it (as compared to Rstudio and other GUIs).

Getting Access: (ssh)

To get onto the server and type code you’ll need to access it through ssh.

  • For Macs (and Linux), open up a terminal and type
    ssh andrew_id@hydra1.stat.cmu.edu

    you will then have to type in your password (if you don’t know it or don’t know it or have never accessed the server before - email remarks@stat.cmu.edu).

  • For Windows, there's a few options (with different pros and cons). Makeuseof provides an overview and introduction to how to get started on a few approaches, including PuTTY and Windows PowerShell. Again, make sure to email remarks@stat.cmu.edu to check that you have an account / or what your password is if you forgot.

If you’re accessing the servers a lot, you might also look into aliases and password storing for the ssh commands. - Mac/Linux: scotch.io - Windows: Powershell: microsoft, PuTTY: makeuseof

Passwordless ssh

To get on the server without typing in the password, you need to first generate a SSH key pair. This creates a private key that identifies your laptop, and a public key that the servers can use to recognize your private key.

  • For Linux or Mac, open up a terminal and check whether you already have a key pair: run ls ~/.ssh and see if you have any files with names starting id_. If you do, you already have a key pair, and you can skip to the ssh-copy-id step below.
  • Next, generate a key pair (both public and private key). There are different types of keys (RSA, ECDSA, and Ed25519). The -t option specifies the type of key pair.
ssh-keygen -t ed25519
  • A prompt for what to name the key pair and what folder to place it in should appear. The username should be the username for your local computer and id_ed25519 is the key pair name. You can change it. The local key should be stored in the ~/.ssh folder on your local computer.
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/username/.ssh/id_ed25519):
  • Hit Enter to accept the default name and location, or enter the folder and name manually.
  • A prompt for a passphrase should appear. This is for securing the local key (on local computer) and is optional. Enter Passphrase (empty for no passphrase):
  • Make sure there is a ~/.ssh folder on the server. If not, make a .ssh folder.
  • Next, upload the public key to remote server. This command will upload the public key to all the hydras and ghidorahs since they share a file system.
ssh-copy-id andrew_id@hydra1.stat.cmu.edu
  • To ensure the permissions of the ~/.ssh directory are updated, log into the hydras and run:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

You should now be able to SSH into the server without being prompted for a password.

File sharing (scp +)

There is also command line code to copy files from your personal computer to the server. This is done with a SCP (secure copy) tool. There are also GUIs (graphical user interfaces) that allow you to “drag and drop” files from your computer to the server (and visa-versa). Currently, a lot of students use GUIs to deal with file sharing.

Command line scp

You can file share either by using scp, for example

  1. Mac/Linux: This command is very similar to cp (the file copier).
    1. Copy from server
       scp username@from_host:path/to/file.txt /local/directory/
      scp -r username@from_host:path/to/folder/ local/directory/
    2. Copy to server  
       scp local/file.txt username@to_host:/remote/directory/
       scp -r local/directory/ username@to_host:/remote/directory/


    scp references: haydenjames.io

  2. Windows: Again, this process is a bit more complicated.
    1. A PuTTY + Command Prompt provides a version that is very similar to Mac/Linux scp (reference: tanaza), and requires minor changes in the call  (pscp -scp instead of scp).
    2. A Powershell specific command is a bit more complicated / not similar to Mac/Linux scp (reference: nsoftware)

 GUI “drag-and-drop” file sharing

A lot of students use GUI interfaces to transfer files instead of scp command line. These tools allow you to “drag and drop” files from one location to another after the connection is set up.

Some examples include:

  1. Mac:
    1. Cyberduck
  2. Linux:
    1. OpenSSH
  3. Windows: lots of options - thegeekstuff
    1. PuTTY
    2. WinSCP

Basic CLI (Linux command line): bash

Understanding the basic Linux command line is important to be able to navigate when you are actually on the server. Below are some based commands to move around the file system, manipulate files, and view storage structure.

command translation
pwd print the current working directory
cd _dir_ change directory
rm _file_ remove / delete file
mv _file_ _dir_ move file (can change name)
cp _file_ _dir_ copy file
ls _dir_ list files in directory

use man _command_ to get a listing / manual of the command.

Additional resources that capture more information on the command line and are still geared to statistical computing can be found here: UCB 2015 reproducible DS lecture notes.

TODO: add information about sed, chmod, and a link to bash files.

Text editors

There are multiple options to view code on the server side. They include:

  • vim
  • … [to be added later]

Running jobs

We have included thoughts about running jobs in two places.

  1. The first looks at tools that allow you to keep running jobs on the server when you close the connection to the server (turn off your laptop, etc.). These tools are call terminal multiplexers. 
  2. The second set of tools focus on how to run your R analysis or Python analysis code on the server.

Server specs

Generally speaking, our servers have multiple CPU cores, but no GPU cores. For deep learning tasks that need GPUs, consider using the GPU cluster.

To examine the specs yourself, use

cat /proc/meminfo
cat /proc/cpuinfo

to see some information.