diff --git a/docs/assets/images/workshops/hpc_exchange/path_search.png b/docs/assets/images/workshops/hpc_exchange/path_search.png new file mode 100644 index 00000000..43f44236 Binary files /dev/null and b/docs/assets/images/workshops/hpc_exchange/path_search.png differ diff --git a/docs/workshops/hpc_exchange/week1/access.md b/docs/workshops/hpc_exchange/week1/access.md index 4bc9bb0d..a1180392 100644 --- a/docs/workshops/hpc_exchange/week1/access.md +++ b/docs/workshops/hpc_exchange/week1/access.md @@ -23,7 +23,7 @@ comes with the `ssh` program already there as well. To use `ssh`, open a Terminal (in any system). And use the command: -```sh +```sh linenums="0" $ ssh USERNAME@CLUSTER.rcac.purdue.edu ``` Where `USERNAME` is replaced with your Purdue username @@ -32,7 +32,7 @@ trying to access. You should see something that looks like this: -``` +``` linenums="0" ************************************************************ ***** Use of Purdue BoilerKey or SSH keys is Required ****** @@ -54,7 +54,7 @@ to the cluster you are trying to get into). When you're logged in, you prompt should change to be of the form of: -``` +``` linenums="0" USERNAME@loginXX.CLUSTER:[~] $ ``` diff --git a/docs/workshops/hpc_exchange/week1/commands.md b/docs/workshops/hpc_exchange/week1/commands.md index 9f10a610..e603d1ec 100644 --- a/docs/workshops/hpc_exchange/week1/commands.md +++ b/docs/workshops/hpc_exchange/week1/commands.md @@ -21,7 +21,7 @@ every time. There are three parts to a command: 3) The argument(s) Here is an example of a copy command -```bash +```bash linenums="0" $ cp --verbose -r example-data data.bak ``` !!! note @@ -40,14 +40,14 @@ As the last part of the command, we have the argument(s). These tell the program Some options are unsupported for different programs. Some programs will be helpful and tell you that the option is invalid. Others will silently fail and you will be left wondering why - ```bash + ```bash linenums="0" $ cp -z example-data data.bak cp: invalid option -- 'z' Try 'cp --help' for more information. ``` Another problem you may run into is a `command not found` error. This happens when the computer doesn't know where to find the program you are trying to run: - ```bash + ```bash linenums="0" $ blah -bash: blah: command not found ``` diff --git a/docs/workshops/hpc_exchange/week1/editing.md b/docs/workshops/hpc_exchange/week1/editing.md index 4a843407..f7f80ede 100644 --- a/docs/workshops/hpc_exchange/week1/editing.md +++ b/docs/workshops/hpc_exchange/week1/editing.md @@ -11,7 +11,7 @@ whitespace as delineating the arguments of a program. So, if you had a folder named `example data`, and ran this command: -```bash +```bash linenums="0" $ ls example data ``` It would try to list everything in the `example` and @@ -22,11 +22,11 @@ you can escape it by using the escape character (`\`) to tell the command line to take that character as is and not try to interpret it. So you could do: -```bash +```bash linenums="0" $ ls example\ data ``` or -```bash +```bash linenums="0" $ ls "example data" ``` @@ -60,11 +60,11 @@ friendly. To start `nano` you can do one of two ways: Simply type `nano` to start it in a new file: -``` +``` linenums="0" $ nano ``` Or provide a file name to start editing that file: -``` +``` linenums="0" $ nano document.txt ``` Nano looks similar to this: @@ -97,7 +97,7 @@ specify and `Exit` quits out of the editor. ### vim: Starting vim is similar to nano, you can either specify a file you want to edit or make, or simply type `vim`: -```bash +```bash linenums="0" $ vim document.txt ``` @@ -126,13 +126,13 @@ the name of the file you want to change it to, or if it's a directory, it's the place you want to put the file. Changing the name of the file: -```bash +```bash linenums="0" $ mv document.txt paper.txt ``` Which will change the name of the file to be `paper.txt` Changing the location of the file: -```bash +```bash linenums="0" $ mv paper.txt ~/Desktop/ ``` Which will move the file into the `Desktop` @@ -141,7 +141,7 @@ directory, but keep the same name. !!! note "Moving Multiple Files" If you provide more than 2 arguments, `mv` will require the last argument to be a destination directory. Like: - ```bash + ```bash linenums="0" mv file1.png file2.png *.txt Desktop ``` @@ -151,7 +151,7 @@ The `cp` or `copy` program is similar to the `mv` program except that it leaves the original copy intact. This is useful if you want to create a backup or a fork of something. The command: -```bash +```bash linenums="0" $ cp ~/example-data/paper.txt ~/thesis.txt ``` @@ -166,14 +166,14 @@ directory, but still keep the original file around. Let's try backing up a directory: -```bash +```bash linenums="0" $ cp example-data/ data.bak cp: example-data/ is a directory (not copied). ``` Oops, what happened here? We can't copy directories without recursively copying its contents, which `cp` does not do by default. You can copy directories with the `-r` (recursive) option: -```bash +```bash linenums="0" $ cp -r example-data/ data.bak ``` @@ -186,7 +186,7 @@ there is no concept of a trash bin, **if you remove a file, it's gone forever, no way to get it back**. So make sure you know what you're deleting before you run `rm`. -```bash +```bash linenums="0" $ rm thesis.txt ``` @@ -194,7 +194,7 @@ To delete directories, you need to use the `-r` or recursive option. This will delete the directory and everything inside of it. Again, this is permanent, so be very careful to know exactly what you're deleting. -```bash +```bash linenums="0" $ rm -r data.bak ``` diff --git a/docs/workshops/hpc_exchange/week1/filesystem.md b/docs/workshops/hpc_exchange/week1/filesystem.md index 050eef3a..19bd90b4 100644 --- a/docs/workshops/hpc_exchange/week1/filesystem.md +++ b/docs/workshops/hpc_exchange/week1/filesystem.md @@ -12,7 +12,7 @@ As a user, you can picture a filesystem as a series of nested files and folders( `pwd` is a program that is occasionally helpful, but is a good way to get your feet wet in trying out different UNIX commands. All it does is print out what directory (folder) you are currently in. Usually you will already know where you're at from the prompt, but it can be helpful to know the full path. `pwd` stands for *print working directory*: -```bash +```bash linenums="0" $ pwd /home/username ``` @@ -21,7 +21,7 @@ $ pwd Most shells start in your home directory! - ```bash + ```bash linenums="0" $ pwd /home/username ``` @@ -30,7 +30,7 @@ $ pwd `ls` is one of the most common UNIX programs that you may use while on UNIX systems. By default, it lists the contents of your current working directory: -```bash +```bash linenums="0" $ ls data.csv Documents bin Desktop ``` @@ -55,12 +55,12 @@ argument to list contents of that directory. You can substitute these in to match specific patterns like so: - ```bash + ```bash linenums="0" $ ls *.txt file1.txt file2.txt file3.txt ``` - ```bash + ```bash linenums="0" $ ls data?.[ct]sv data1.csv data2.tsv data3.csv ``` @@ -69,7 +69,7 @@ argument to list contents of that directory. Check with `$ ls --all`! These will vary depending on what you have installed, but most will be configuration files for programs you have installed. Common ones are: - ``` + ``` linenums="0" .bashrc - bash startup customization file .conda - Conda python environments .cache - Cached data (like photo thumbnails) @@ -87,7 +87,7 @@ is `cd`, which stands for *change directory*, but should be thought of as *change working directory*. This will change which directory you are currently working in. -``` +``` linenums="0" $ pwd /home/username $ cd Desktop/data @@ -120,13 +120,13 @@ $ pwd The last program we'll go over in this section is the `mkdir` or *make directory* command. This does what it sounds like and will create the directory noted in the argument if it doesn't already exist. -``` +``` linenums="0" $ mkdir example-data ``` You can also put multiple arguments and `mkdir` will create all of them. A helpful option to pass to the `mkdir` program is `-p`, which will create parent directories as needed. -``` +``` linenums="0" $ mkdir -p another_one/test1 ``` Which will create the `another_one` directory in your current @@ -137,14 +137,14 @@ directory. There are several ways! We could first `cd` to the Desktop, and run `mkdir`: - ```bash + ```bash linenums="0" cd /home/user/Desktop mkdir myfolder ``` Or we could make it from our home directory by specifying the path: - ```bash + ```bash linenums="0" mkdir Desktop/myfolder ``` @@ -159,12 +159,12 @@ a slash (`/`). Relative paths are relative to your current working directory and do not start with a slash. ### Absolute path -``` +``` linenums="0" $ ls /home/username/Desktop output_of_ls ``` ### Relative path -``` +``` linenums="0" $ ls Desktop output_of_ls ``` @@ -180,7 +180,7 @@ UNIX file systems: * The `-` represents the previous working directory (the directory you were in before your current one) * You can run `cd -` to navigate to the previous directory you were in. -```bash +```bash linenums="0" $ cd Desktop/data $ cd - $ pwd @@ -203,7 +203,7 @@ $ pwd * The `..` represents the parent directory of the directory you are currently in. For example, if you are in `/home/username/Documents/mydata`, the command `cd ..` will change your directory to `/home/username/Documents` * You can also stack these! For example, to move "up" two directories, you could use the command `cd ../../` -```bash +```bash linenums="0" $ cd Desktop/data $ cd .. $ pwd @@ -213,7 +213,7 @@ $ pwd ![cd dot dot ](/assets/images/workshops/hpc_exchange/cd_dotdot.png) ??? question "How would we move from the `data` directory to the Downloads directory with one command?" - ```bash + ```bash linenums="0" cd ../../Downloads ``` @@ -225,8 +225,8 @@ the command `ls -l` which runs the `ls` program with the `l` option which tells `ls` to print out more information about the files. The following code block shows an example of what you might see from -the longer `ls` output: -```bash +the longer `ls` output of your `.ssh` directory: +```bash linenums="0" $ ls -a -l -h ~/.ssh total 6.0K drwxr-xr-x 2 username student 4 Jul 17 11:19 . @@ -235,9 +235,11 @@ drwx------ 14 username student 28 Jul 16 22:26 .. -rw-r--r-- 1 username student 0 Jul 17 11:19 config ``` -The three program options used here are: `a`, which displays all files/folders, -even hidden ones; `l` which lists out more information about each listing; -and `h` which shows the size of items in a human-readable format. +The three program options used here are: + +* `a`, which displays all files/folders,even hidden ones +* `l` which lists out more information about each listing +* `h` which shows the size of items in a human-readable format In the first ten columns of the output are the permissions of that item, details of which will be discussed in the next paragraph. The next number is the number of hardlinks to the file, which for most use cases isn't important. @@ -304,7 +306,7 @@ hear the term *man page* which is just short for *manual page*, or running the program `man` with the argument being the program you want more information about. -``` +``` linenums="0" $ man ls ``` The `man` program pulls up a page that you can scroll up and down @@ -313,13 +315,5 @@ pressing the `q` key. It is up to each program to provide its own `man` page, so not all programs have them, but when they do it can be helpful. - Next section: [Editing Files](./editing.md) \ No newline at end of file diff --git a/docs/workshops/hpc_exchange/week1/index.md b/docs/workshops/hpc_exchange/week1/index.md index 729f51da..26a173fb 100644 --- a/docs/workshops/hpc_exchange/week1/index.md +++ b/docs/workshops/hpc_exchange/week1/index.md @@ -1,7 +1,7 @@ # Week 1 This is the outline for our first week of the HPC Exchange. It is -an intoduction to Unix and how to use it. We will discuss how to +an introduction to Unix and how to use it. We will discuss how to navigate the filesystem and common commands you may encounter while working with Unix systems. diff --git a/docs/workshops/hpc_exchange/week1/reference.md b/docs/workshops/hpc_exchange/week1/reference.md index b363b41d..938bb7b6 100644 --- a/docs/workshops/hpc_exchange/week1/reference.md +++ b/docs/workshops/hpc_exchange/week1/reference.md @@ -26,13 +26,13 @@ 1) Open a terminal and make a directory on your Desktop called "`practice1`" ??? tip "solution" - ```bash + ```bash linenums="0" [~]$ mkdir ~/Desktop/practice1 ``` 2) Change your directory to `practice1`, and print your directory. ??? tip "solution" - ```bash + ```bash linenums="0" [~]$ cd ~/Desktop/practice1 [~/Desktop/practice1]$ pwd /home/username/Desktop/practice1 @@ -41,7 +41,7 @@ 3) Create a file called `test1.txt` in the `practice1` containing the text "This is super important!" using `vim` or `nano` ??? tip "solution" - ```bash + ```bash linenums="0" [~/Desktop/practice1]$ vim test1.txt ``` @@ -54,7 +54,7 @@ 4) Create another file called `test2.txt` with the text "This is not important" in the `practice1` folder. ??? tip "solution" - ```bash + ```bash linenums="0" [~/Desktop/practice1]$ vim test2.txt ``` @@ -67,7 +67,7 @@ 5) Without changing directories, make a different folder on your desktop called `practice2`, and copy both of your text files into that folder. ??? tip "solution" - ```bash + ```bash linenums="0" [~/Desktop/practice1]$ mkdir ../practice2 [~/Desktop/practice1]$ cp *.txt ../practice2 ``` @@ -75,7 +75,7 @@ 6) Now change directories into practice2, and rename `test1.txt` to a file called `.hidden`. ??? tip "solution" - ```bash + ```bash linenums="0" [~/Desktop/practice1]$ cd ../practice2 [~/Desktop/practice2]$ mv test1.txt .hidden ``` @@ -84,7 +84,7 @@ ??? tip "solution" - ```bash + ```bash linenums="0" [~/Desktop/practice2]$ ls -la drwxrwxr-x 2 username groupname 4096 Jan 29 14:23 . drwxr-xr-x 7 username groupname 4096 Jan 29 14:21 .. @@ -96,7 +96,7 @@ 7) Switch back to `practice1` using the shortcut for "previous working directory" ??? tip "solution" - ```bash + ```bash linenums="0" [~/Desktop/practice2]$ cd - ``` @@ -104,14 +104,14 @@ 8) In a single command, move the entire `practice2` directory *into* `practice1` ??? tip "solution" - ```bash + ```bash linenums="0" [~/Desktop/practice1]$ mv ../practice2 . ``` 9) move back to your desktop using the notation for "parent directory" ??? tip "solution" - ```bash + ```bash linenums="0" [~/Desktop/practice1]$ cd .. [~/Desktop]$ ``` @@ -119,7 +119,7 @@ 10) remove the `practice1` directory, and show the files that are being removed. ??? tip "solution" - ```bash + ```bash linenums="0" [~/Desktop]$ rm -r --verbose ./practice1 ``` diff --git a/docs/workshops/hpc_exchange/week1/setup.md b/docs/workshops/hpc_exchange/week1/setup.md index d63d2129..d04a995d 100644 --- a/docs/workshops/hpc_exchange/week1/setup.md +++ b/docs/workshops/hpc_exchange/week1/setup.md @@ -79,7 +79,7 @@ start menu. ![Git Bash Window](/assets/images/workshops/hpc_exchange/git_bash.png) * Microsoft has also Developed the "Windows Subsystem for Linux" (WSL) which allows you to run Ubuntu Linux within Windows. * Installation Instructions can be found [here](https://learn.microsoft.com/en-us/windows/wsl/install). - ```powershell + ```powershell linenums="0" wsl --install ubuntu ``` diff --git a/docs/workshops/hpc_exchange/week1/shell.md b/docs/workshops/hpc_exchange/week1/shell.md index 3bd27560..ce204a8e 100644 --- a/docs/workshops/hpc_exchange/week1/shell.md +++ b/docs/workshops/hpc_exchange/week1/shell.md @@ -18,7 +18,7 @@ One important aspect of the shell is the prompt, which shows you information about your shell session. A typical shell could look like this: -``` +``` linenums="0" username@login03.negishi:[~] $ ``` diff --git a/docs/workshops/hpc_exchange/week1/unix.md b/docs/workshops/hpc_exchange/week1/unix.md index 98f48835..8d681d61 100644 --- a/docs/workshops/hpc_exchange/week1/unix.md +++ b/docs/workshops/hpc_exchange/week1/unix.md @@ -59,17 +59,7 @@ system for servers (both in HPC and Cloud scenarios). As apposed to operating systems like Windows, UNIX systems offer a strong, text-based workflow that is ideal for remote access, scripting, and automation. We'll cover more of scripting and automation in [Week 3](../week3/index.md). -## Unix components - -UNIX systems are typically made up of three main components -that we will discuss in the following text. The three -components are: - -* The File system hierarchy standard -* The Executable and library format -* The shell - -### File system hierarchy +## Unix File system hierarchy In UNIX systems, there is a conventional layout of the file system directories. There are **standard structures, names and purposes for different directories.** Some names exist only at the root of the file system and others are repeated in layers for a similar purpose or function. Some common directories you may see are: @@ -83,7 +73,7 @@ Some names exist only at the root of the file system and others are repeated in There's lots of other top-level directories that you might come across like `/boot`, `/sys`, `/mnt`, `/tmp`, and others. Luckily, as a user you rarely will have to deal with these. Almost all of your day to day work is done in `/home`. -### Everything is a file +## Everything is a file A core UNIX design principle is that **everything is treated as a file**. @@ -97,7 +87,7 @@ This means: --- -### Metadata & Permissions +## Metadata & Permissions Every file has **metadata** that describes: @@ -110,18 +100,7 @@ These properties form the basis of UNIX security and access control. --- -### Executables and libraries - -Programs in UNIX are just files. - -* **Executables** are files that can be run as programs. -* **Libraries** are shared code files that executables depend on at runtime. - -The operating system uses file metadata and standardized binary formats to determine **how programs are loaded, linked, and executed**. - ---- - -### The Shell +## The Shell The **shell** is the primary interface for interacting with a UNIX system. diff --git a/docs/workshops/hpc_exchange/week2/access.md b/docs/workshops/hpc_exchange/week2/access.md index c316c39f..b2e644fb 100644 --- a/docs/workshops/hpc_exchange/week2/access.md +++ b/docs/workshops/hpc_exchange/week2/access.md @@ -18,7 +18,7 @@ choose which option(s) makes the most sense for you. `ssh` is the simplest way to access the cluster. Most UNIX systems (such as Linux and macOS) have the `ssh` program already installed. Windows 11 comes with the `ssh` program already there as well. To use `ssh`, open a Terminal (in any system). And use the command: -```sh +```sh linenums="0" $ ssh USERNAME@CLUSTER.rcac.purdue.edu ``` Where `USERNAME` is replaced with your Purdue username @@ -27,7 +27,7 @@ trying to access. You should see something that looks like this: -``` +``` linenums="0" ************************************************************ ***** Use of Purdue BoilerKey or SSH keys is Required ****** @@ -49,7 +49,7 @@ to the cluster you are trying to get into). When you're logged in, you prompt should change to be of the form of: -``` +``` linenums="0" USERNAME@loginXX.CLUSTER:[~] $ ``` diff --git a/docs/workshops/hpc_exchange/week2/applications.md b/docs/workshops/hpc_exchange/week2/applications.md index 414ad0ec..d5cb5a9d 100644 --- a/docs/workshops/hpc_exchange/week2/applications.md +++ b/docs/workshops/hpc_exchange/week2/applications.md @@ -42,7 +42,7 @@ This script creates two random matrices, of size five thousand by five thousand Next, let's try running it: -``` +``` linenums="0" $ python example.py -bash: python: command not found ``` @@ -56,7 +56,7 @@ There are too many versions and conflicting software to have every version of ev As an example, run the command `module list` to list all currently loaded modules: -``` +``` linenums="0" $ module list Currently Loaded Modules: @@ -82,7 +82,7 @@ There are many different `module` commands that we can use to learn about what's If we want to run a python script, we'll need to load a module that provides the `python` command. On RCAC clusters, we provide python through the `conda` environment manager, which is available as a module. -``` +``` linenums="0" $ module avail conda ---- Core Applications ---- @@ -90,7 +90,7 @@ conda/2024.09 ``` Now let's load conda to get our python loaded in! -``` +``` linenums="0" $ module load conda $ which python @@ -100,7 +100,7 @@ $ which python * `which` is a nice program that will tell us where the specified program is coming from. Remember that everything is a file! `which` tells you what file starts the program when you run a command. Now that we have python ready and our script is written, let's run it: -``` +``` linenums="0" $ python example.py 2499.9118 ``` @@ -109,7 +109,7 @@ $ python example.py !!! bug "Numpy error" On some RCAC systems, the `numpy` library isn't available in the "base" conda environment, and you may need to make your own python environment, and you may see errors like this: - ``` + ``` linenums="0" Traceback (most recent call last): File "/home/username/example.py", line 1, in import numpy as np @@ -118,7 +118,7 @@ $ python example.py We're going to make our own conda environment to install `numpy` for ourselves. Run these three lines of code to create the environment, activate it, and then run our example: -```bash +```bash linenums="0" $ conda create -y -n example_env numpy $ conda activate example_env (example_env) $ python example.py @@ -127,25 +127,26 @@ $ conda activate example_env The first line creates a new conda environment named `example_env`, and automatically installs the `numpy` package in it. The second line changes your shell behavior so that it is using your new conda environment. You can tell that the environment is activated as conda will alter your prompt to contain the environment name. If you check which python you are using after you run `conda activate example`, you'll see that now your using a `python` that's installed in your home directory! -```bash +```bash linenums="0" $ conda activate example_env (example_env) $ which python ~/.conda/envs/example/bin/python ``` -`conda` environments like this are often an easy way to install packages and libraries without the need for `sudo` (admin) privileges. +!!! tip + `conda` environments like this are often an easy way to install packages and libraries without the need for `sudo` (admin) privileges. ## Putting it into a Script Notice that it took several shell commands to run this python program. If we don't want to type out all the commands every time we want to run, we can put them into a script! We'll talk about scripting more in [week 3](../week3/index.md), but for now we can think of a script as a series of commands that we put into a file, that are all ran when we run the script. For example, if we put our commands in a file titled `run_example.sh`: -```bash title="run_example.sh" linenums="1" +```bash title="run_example.sh" linenums="1" #!/bin/bash module load conda conda activate example_env python example.py ``` We can run the whole script on the command line: -```bash +```bash linenums="0" $ bash run_example.sh 2499.9118 ``` diff --git a/docs/workshops/hpc_exchange/week2/clusters.md b/docs/workshops/hpc_exchange/week2/clusters.md index 0448854e..8485db1d 100644 --- a/docs/workshops/hpc_exchange/week2/clusters.md +++ b/docs/workshops/hpc_exchange/week2/clusters.md @@ -49,7 +49,7 @@ Gilbreth is a GPU-focused community cluster supporting a wide range of NVIDIA GP * GPU-accelerated simulation * Data analytics and visualization -Gilbreth supports a diverse set of GPU node types, enabling flexibility for different performance and memory requirements. Importantly, jobs submitted to Gautschi **MUST** request and use GPUs. +Gilbreth supports a diverse set of GPU node types, enabling flexibility for different performance and memory requirements. Importantly, jobs submitted to Gilbreth **MUST** request and use GPUs. ## Scholar (Teaching Resource) diff --git a/docs/workshops/hpc_exchange/week2/slurm-basics.md b/docs/workshops/hpc_exchange/week2/slurm-basics.md index cf6f107c..bc342697 100644 --- a/docs/workshops/hpc_exchange/week2/slurm-basics.md +++ b/docs/workshops/hpc_exchange/week2/slurm-basics.md @@ -51,7 +51,7 @@ echo "Script is finished! Exiting..." ### Submission Once you are ready, submit it to the scheduler with the `sbatch` program: -```bash +```bash linenums="0" $ ls example.py myjob.sh ... @@ -64,7 +64,7 @@ Submitted batch job 32209880 The output of your job will, by default, be saved in files with this ID (e.g. `slurm-32209880.out`). Once our job is done, we can see the output with: - ```bash + ```bash linenums="0" $ ls slurm-32209880.out slurm-32209880.out @@ -92,7 +92,7 @@ Let's take a closer look at the individual pieces of information we need to prov Use the `slist` program to show which Slurm accounts are available for you to submit to, and what their current usage is. - ``` + ``` linenums="0" $ slist Current Negishi Accounts ============================================================================== @@ -122,7 +122,7 @@ Let's take a closer look at the individual pieces of information we need to prov available on the cluster, run the `showpartitions` program: - ``` + ``` linenums="0" $ showpartitions Partition statistics for cluster negishi at Thu Jul 17 16:12:58 EDT 2025 Partition #Nodes #CPU_cores Cores_pending Job_Nodes MaxJobTime Cores Mem/Node @@ -201,7 +201,7 @@ Let's take a closer look at the individual pieces of information we need to prov To get an interactive job (or essentially a shell on a compute node), use the `sinteractive` program (which is RCAC specific). You will need to specify the same parameters as with `sbatch` (e.g. account, partition, QoS, cores, nodes, time). -``` hl_lines="1 8" +``` hl_lines="1 8" linenums="0" username@login03.negishi:[~] $ sinteractive -A hpcexc -p cpu -q normal -n 1 -t 00:10:00 salloc: Pending job allocation 19809515 salloc: job 19809515 queued and waiting for resources @@ -233,7 +233,7 @@ Most notably, we have an "Open OnDemand Desktop" application, which will give yo You can use the `squeue` program to list currently scheduled (pending and running) jobs. By default it will show all jobs from all users on the cluster, which leads to a lot of output. You can limit this to just your jobs with the `--me` flag: -```bash +```bash linenums="0" $ squeue --me JOBID USER ACCOUNT PART QOS NAME NODES TRES_PER_NODE CPUS TIME_LIMIT ST TIME 32541229 username hpcexc cpu normal interactiv 1 N/A 8 30:00 R 0:09 @@ -244,7 +244,7 @@ This can give you important information such as the status of your job (`R` for To learn more about the parameters of a single job, you can use the `jobinfo` program. To use `jobinfo`, the command would be `jobinfo JOB_ID`, where the `JOB_ID` is replaced with the job ID mentioned above (which you can also check with the `squeue` program). -```bash +```bash linenums="0" $ jobinfo 32209880 Name : myjob.sh User : username @@ -259,7 +259,7 @@ There are also `jobenv`, `jobcmd`, and `jobscript` programs that tell you more i To cancel a job, use the `scancel` program. It used by running `scancel JOB_ID`, where `JOB_ID` is replaced with the job ID mentioned before. -```bash +```bash linenums="0" $ scancel 32209880 ``` diff --git a/docs/workshops/hpc_exchange/week2/storage-transfer.md b/docs/workshops/hpc_exchange/week2/storage-transfer.md index 6ca05961..e2341348 100644 --- a/docs/workshops/hpc_exchange/week2/storage-transfer.md +++ b/docs/workshops/hpc_exchange/week2/storage-transfer.md @@ -72,37 +72,38 @@ the clusters: `scp` stands for `secure copy protocol` and is the server version of the `cp` we saw last week. It needs a source and a destination, but one of them may be a server. Copying to a cluster: - ```bash + ```bash linenums="0" $ scp ./source_file USERNAME@CLUSTER.rcac.purdue.edu:~/some_dir/cluster_file_name ``` Copying from a cluster: - ```bash + ```bash linenums="0" $ scp USERNAME@CLUSTER.rcac.purdue.edu:~/some_dir/cluster_file_name ./destination_file ``` - When copying from a cluster, the destination file will go into the directory you are currently in. You can also specify a path you want the destination file to go to. This path can be either relative, or absolute. + + Notice that in either the source or the destination, you can specify the server you plan on copying to/from. For example `USERNAME@negishi.rcac.purdue.edu:~/` is referring to your home directory on Negishi, which you can copy to or from. === "rsync" `rsync` is similar to `scp`, but much more fully-featured. It is especially useful for transferring directories, syncing changed files, and resuming interrupted transfers. Copying a file to a cluster: - ```bash + ```bash linenums="0" $ rsync ./source_file USERNAME@CLUSTER.rcac.purdue.edu:~/some_dir/cluster_file_name ``` Copying a file from a cluster: - ```bash + ```bash linenums="0" $ rsync USERNAME@CLUSTER.rcac.purdue.edu:~/some_dir/cluster_file_name ./destination_file ``` Copying a directory to a cluster: - ```bash - $ rsync -av ./my_directory/ USERNAME@CLUSTER.rcac.purdue.edu:~/some_dir/ + ```bash linenums="0" + $ rsync -a ./my_directory/ USERNAME@CLUSTER.rcac.purdue.edu:~/some_dir/ ``` Copying a directory from a cluster: - ```bash - $ rsync -av USERNAME@CLUSTER.rcac.purdue.edu:~/some_dir/my_directory/ ./my_directory/ + ```bash linenums="0" + $ rsync -a USERNAME@CLUSTER.rcac.purdue.edu:~/some_dir/my_directory/ ./my_directory/ ``` A few common options are: @@ -125,7 +126,7 @@ the clusters: use the `get` and `put` programs to transfer to and from the cluster you are connected to: - ```bash + ```bash linenums="0" $ sftp USERNAME@CLUSTER.rcac.purdue.edu (transfer TO CLUSTER) @@ -142,15 +143,6 @@ the clusters: --- - - ## Helpful RCAC programs for file management @@ -166,7 +158,7 @@ where you have access to read and write files. It also tells you what the space quotas are for each of those spaces and how much you have used already. We'll talk more about filesystems in [Week 4](../week4/storage-transfer.md#file-storage-and-transfers) -```bash +```bash linenums="0" $ myquota Type Location Size Limit Use Files Limit Use =============================================================== @@ -179,7 +171,7 @@ depot group 92.0MB 1.0TB 1% - - - RCAC regularly backs up data in home and depot spaces, so that if something is accidentally deleted or overwritten, it can be recovered (if it's been there sufficiently long). We have daily, weekly, and monthly snapshots for varying amounts of time. If you lost something in your scratch space, we don't have backups of those, so you're out of luck. -``` +``` linenums="0" $ flost This script will help you try to recover lost home or group directory contents. NB: Scratch directories are not backed up and cannot be recovered. diff --git a/docs/workshops/hpc_exchange/week2/what-is-a-cluster.md b/docs/workshops/hpc_exchange/week2/what-is-a-cluster.md index 3bdd472c..1d70e69c 100644 --- a/docs/workshops/hpc_exchange/week2/what-is-a-cluster.md +++ b/docs/workshops/hpc_exchange/week2/what-is-a-cluster.md @@ -36,12 +36,12 @@ When you log into the cluster, you are put onto a login node, which is limited i ![Overview of cluster](/assets/images/workshops/hpc_exchange/cluster_overview.png) You can typically tell what node (and node type) you are on by looking at your command prompt: -``` +``` linenums="0" user@login00 ~ $ ``` or by using the `hostname` command: -```bash +```bash linenums="0" $ hostname login00.cluster.rcac.purdue.edu ``` diff --git a/docs/workshops/hpc_exchange/week3/control-flow.md b/docs/workshops/hpc_exchange/week3/control-flow.md index 397da4a9..466af82a 100644 --- a/docs/workshops/hpc_exchange/week3/control-flow.md +++ b/docs/workshops/hpc_exchange/week3/control-flow.md @@ -11,14 +11,14 @@ In Bash, **commands return an exit code**: * `0` → success (true) * non-zero → failure (false) -```bash +```bash linenums="0" ls /tmp # success → exit code 0 ls /nope # failure → exit code != 0 ``` You can check the last exit code with: -```bash +```bash linenums="0" echo $? ``` This is the foundation for conditionals in shell scripts. @@ -28,7 +28,7 @@ This is the foundation for conditionals in shell scripts. ### Basic `if`/`else` statements -```bash +```bash linenums="0" if command; then echo "Command succeeded" else @@ -50,7 +50,7 @@ fi | `-x file` | Executable | -```bash +```bash linenums="0" if [[ -d "$SCRATCH" ]]; then echo "Scratch directory exists" fi @@ -65,7 +65,7 @@ fi | `str1 == str2` | Equal | | `str1 != str2` | Not equal | -```bash +```bash linenums="0" if [[ -z "$1" ]]; then echo "Usage: $0 " exit 1 @@ -83,7 +83,7 @@ fi | `-gt` | greater than | | `-ge` | greater or equal | -```bash +```bash linenums="0" if [[ "$N" -gt 10 ]]; then echo "Large job" fi @@ -97,7 +97,7 @@ fi | `||` | OR | | `!` | NOT | -```bash +```bash linenums="0" if [[ -f input.dat && -d /path/to/data ]]; then echo "Input file and Data directory present!" fi @@ -108,7 +108,7 @@ fi ### Basic For loop -```bash +```bash linenums="0" for x in a b c; do echo "$x" done @@ -116,7 +116,7 @@ done ### Loop Over Files -```bash +```bash linenums="0" for f in *.py; do echo "Processing $f" python $f @@ -125,7 +125,7 @@ done ### Numeric Loop -```bash +```bash linenums="0" for i in {1..5}; do echo "Iteration $i" done @@ -133,7 +133,7 @@ done Alternatively, -```bash +```bash linenums="0" for ((i=1; i<=5; i++)); do echo "$i" done @@ -145,7 +145,7 @@ done While loops are also available in bash. Note that this example uses an expression to increment `count`. -```bash +```bash linenums="0" count=0 while [ "$count" -lt 5 ]; do echo "$count" @@ -157,7 +157,7 @@ done One of the most common uses of a while loop is using a file. Note that this example uses a `<` to read input from a file. We'll talk more about this in the [pipes](./pipes.md) section! -```bash +```bash linenums="0" while read -r line; do echo "$line" done < input.txt @@ -166,7 +166,7 @@ done < input.txt ## Examples -```bash +```bash linenums="0" #!/bin/bash if [[ -z "$SLURM_JOB_ID" ]]; then diff --git a/docs/workshops/hpc_exchange/week3/files-directories.md b/docs/workshops/hpc_exchange/week3/files-directories.md index 7062421d..dca89549 100644 --- a/docs/workshops/hpc_exchange/week3/files-directories.md +++ b/docs/workshops/hpc_exchange/week3/files-directories.md @@ -40,7 +40,7 @@ big file instead of many, smaller files. We will learn more on how to archive da To package a directory into a single, compressed file, you would use the following command: -```bash +```bash linenums="0" $ tar -cvzf example-data.tar.gz example-data/ ``` In the example above, we supplied four options @@ -58,7 +58,7 @@ To undo the archiving, simply swap the `c` option for the `x` option (which stands for extract): -```bash +```bash linenums="0" $ tar -xvzf example-data.tar.gz ``` @@ -67,7 +67,7 @@ $ tar -xvzf example-data.tar.gz The `zip` program is simpler to use, but often people prefer `tar` over `zip`. -```bash +```bash linenums="0" $ zip -r archive-name.zip example-data/ $ unzip archive-name.zip ``` @@ -94,21 +94,21 @@ usage and behavior. The three are: #### `gzip` (`.gz`) -```bash +```bash linenums="0" $ gzip *.txt $ cat *.gz | gunzip ``` #### `bzip2` (`.bz2`) -```bash +```bash linenums="0" bzip2 file.txt bunzip2 file.txt.bz2 ``` #### `xz` (`.xz`) -```bash +```bash linenums="0" xz file.txt unxz file.txt.xz ``` @@ -123,7 +123,7 @@ When you have a lot of files, it can be useful to have a program to find files that match a pattern. To do this, use the `find` program. -```bash +```bash linenums="0" $ find ~ -type f -name "*.txt" | grep "example-data" ~/example-data/paper.txt ``` @@ -136,7 +136,7 @@ what kind of listing the command will find. Putting `f` here narrows the search to just find regular files. - The `-name` option filters the search to only list the files +The `-name` option filters the search to only list the files and such that follow the pattern given, in this case, everything that ends in `.txt` (Remember that `*` is a wildcard that matches any number of any characters!). diff --git a/docs/workshops/hpc_exchange/week3/pipes.md b/docs/workshops/hpc_exchange/week3/pipes.md index 75c426c3..7383b4f7 100644 --- a/docs/workshops/hpc_exchange/week3/pipes.md +++ b/docs/workshops/hpc_exchange/week3/pipes.md @@ -7,7 +7,7 @@ When dealing with processes, the output of those processes is important. In this ### Standard file descriptors When a program often write output to the console, -this is called *standard output*, or `stdout`. The shell defines `stdin`, `stdout`, and `stderr` for every program. +this is called *standard output*, or `stdout`. The shell defines `stdin`, `stdout`, and `stderr` for every program, often denoted with a by a 0, 1, and 2. | # | Common name | Description | |---|---|---| @@ -34,13 +34,13 @@ You can also redirect these file descriptors to attach to files other than the c The following example redirects the `stdout` from our program (the "Hello, world!" text it prints) from the console into the file `message.txt`. -```bash +```bash linenums="0" $ hello > message.txt ``` You can concatenate (print) the contents of files with the `cat` program: -```bash +```bash linenums="0" $ cat message.txt Hello, world! ``` @@ -51,7 +51,7 @@ Hello, world! We can also use the output (`stdout`) of the `cat` program (again, the "Hello, World!" text) to the input (`stdin`) of another program with a pipe(`|`). We'll pass the output to the `wc` "word count" program which can count the words, lines, chars, etc of the provided input. -``` +``` linenums="0" $ cat message.txt | wc --chars 14 ``` @@ -66,8 +66,8 @@ $ cat message.txt | wc --chars ??? question "How might we see how many files we have in our current directory?" We could get a list of our files with `ls`, and pass the output to `wc` to count the number of lines. - ```bash - ls | wc --lines + ```bash linenums="0" + ls -1 | wc --lines 55 ``` diff --git a/docs/workshops/hpc_exchange/week3/processes.md b/docs/workshops/hpc_exchange/week3/processes.md index 0aeaed9e..390ead8f 100644 --- a/docs/workshops/hpc_exchange/week3/processes.md +++ b/docs/workshops/hpc_exchange/week3/processes.md @@ -13,7 +13,7 @@ To run programs in the background, add a single trailing ampersand (`&`) to the command. -```bash +```bash linenums="0" $ sleep 600 & [1] 1298141 @@ -28,23 +28,23 @@ are going. After the program is put in the background, the shell tells you -two numbers. The first number is -the relative job ID, -relative to the number of child -processes. The second number is -the system process ID (PID). +two numbers. + +* The relative job ID,(relative to the number of child processes) + +* The system process ID (PID). You can check on your shell's child processes with the `jobs` program. -``` +``` linenums="0" $ jobs [1]+ Running sleep 600 & ``` You can also check on ALL running processes with the `ps` command. -``` +``` linenums="0" $ ps -u username PID TTY TIME CMD 221965 ? 00:00:00 systemd @@ -54,23 +54,20 @@ PID TTY TIME CMD 222170 pts/10 00:00:00 sleep 222182 pts/10 00:00:00 ps ``` - +## Waiting -You can wait nicely for all jobs -in the background to complete with -the `wait` program. +If you want your shell (or script) to wait for all background processes to finish before continuing: -```bash +```bash linenums="0" $ wait ``` +After using the `wait` command, you'll notice that you no longer have control of your shell. That's because it's waiting for all backrounded processes to finish before completing. + + +## Re-Attaching You can also re-attach to background processes with the `fg` program. This code will bring the `sleep 600` @@ -79,7 +76,7 @@ will wait for it to finish before giving you back control of the command line. -```bash +```bash linenums="0" $ sleep 600 & [1] 1240872 $ fg @@ -88,7 +85,7 @@ sleep 600 You can also use `ctrl+z` to pause a job actively running in the shell, and then `bg` to resume it in the background: -```bash +```bash linenums="0" $ sleep 600 [ctrl+z] [1]+ Stopped sleep 600 @@ -98,6 +95,8 @@ $ jobs [1]+ Running sleep 600 & ``` +## Interrupting Processes + Lastly, you can interrupt processes with the `kill` command (using `%` for the @@ -113,14 +112,16 @@ $ kill -s int %1 The `kill` program can technically send *any* signal to a program (despite its ominous name). In the example above, -we have sent the `int` signal to the +we have sent the interrupt (`int`) signal to the first child process. This interrupts the process and tries to stop it. + ### Program reference diff --git a/docs/workshops/hpc_exchange/week3/scripting.md b/docs/workshops/hpc_exchange/week3/scripting.md index cd348882..dff29185 100644 --- a/docs/workshops/hpc_exchange/week3/scripting.md +++ b/docs/workshops/hpc_exchange/week3/scripting.md @@ -61,14 +61,14 @@ There are two ways to execute shell scripts: 1) Invoking it with the appropriate shell -```bash +```bash linenums="0" $ bash hello.sh Hello, World! ``` 2) Refer to it as a program directly by its path -```bash +```bash linenums="0" $ ./hello.sh -bash: ./hello.sh: Permission denied ``` @@ -76,7 +76,7 @@ $ ./hello.sh !!! failure "Execution Permissions" Why did this happen? What can we do to check the permissions? Use the command `ls -l hello.sh` to see the permissions: - ``` + ``` linenums="0" $ ls -l hello.sh -rw-r--r-- 1 username student 22 Oct 11 01:44 hello.sh ``` @@ -85,11 +85,11 @@ The file `hello.sh` doesn't have the **execute** bit set, so we can't run it as The `chmod` program allows you to add and remove read(`r`)/write(`w`)/execute(`x`) permissions for the user (`u`), group (`g`), and others (`o`) with the following syntax: -```bash +```bash linenums="0" chmod [ugo][-+][rwx] file ``` To add execute permissions to our file, we can simply run the command: -```bash +```bash linenums="0" $ chmod +x hello.sh ``` @@ -106,13 +106,13 @@ which allows us to "execute" it as a program. For a quick refresher on what perm Now, we can run `hello.sh` directly as a program! -```bash +```bash linenums="0" $ ./hello.sh Hello, World! ``` ??? question "How would we remove read permissions on a file for both the file *group* and *others*?" - ``` + ``` linenums="0" chmod go-r file.sh ``` @@ -121,29 +121,34 @@ Hello, World! You may have noticed that we needed to execute our file relative to our current directory (i.e `./hello.sh` instead of just `hello.sh`). If we try to run just `hello.sh`, we will get a "command not found" error: -```bash +```bash linenums="0" $ hello.sh hello.sh: command not found ``` In order for a shell to be able to find this little program and use it as a command, we need to add the directory it is located in to be part of our `PATH` variable. (We'll talk more on shell variables in a bit). -Essentially,the `PATH` variable controls where the shell looks for executable programs to run as commands. You can see all the directories that are searched for commands with the following command: +Essentially, the `PATH` variable controls where the shell looks for executable programs to run as commands. You can see all the directories that are searched for commands with the following command: -```bash +```bash linenums="0" echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin: ``` -Every command that we run is located in one of these directories! For example, we can see that the program that is executed by the `ls` command is located in `/usr/bin/`, which is listed in our `PATH` variable! +Every command that we run is located in one of these directories! When you type a command, your shell will look through all of the directories on your `PATH` variable until it finds a matching executable file! + +![Image of a shell searching through folders on the path variable until it finds a matching command](../../../assets/images/workshops/hpc_exchange/path_search.png) + +For example, we can see that the program that is executed by the `ls` command is located in `/usr/bin/`, which is listed in our `PATH` variable! + -```bash +```bash linenums="0" $ which ls /usr/bin/ls ``` It's common to make a `bin` directory in your home directory, and store any executable files you want to run as commands there. Let's make a `bin` directory, move our program there, and add the `bin` directory to our `PATH` variable! -```bash +```bash linenums="0" $ mkdir ~/bin $ mv hello.sh ~/bin/hello $ export PATH=$PATH:~/bin @@ -184,14 +189,14 @@ by environment variables. They are like other programming languages, and you can define them yourself! There are no types (mostly everything is text). Simple assignment: -```bash +```bash linenums="0" x=1 y=foo ``` You can access the variable with with the `$var` or `${var}`: -```bash +```bash linenums="0" echo $x 1 echo ${y} @@ -201,20 +206,20 @@ foo Variables are *conventionally* uppercase, but it's not necessary. -```bash +```bash linenums="0" NAME="some data" ``` There is also a weird thing where 0 is true and 1 is false, which we will discuss later. -```bash +```bash linenums="0" COND=1 ``` Lastly, you can use **Command substitution** to set a variable to the output of a command: -```bash +```bash linenums="0" HOST=$(hostname -f) ``` @@ -224,7 +229,7 @@ Variables also have a scope. If you define a variable, it is only visible in local scope (current script) by default. -```bash +```bash linenums="0" X=true ``` @@ -232,20 +237,20 @@ X=true To propagate the variable down to child processes, you need to `export` it. -```bash +```bash linenums="0" export X ``` You can also declare the variable and export it on the same line. -```bash +```bash linenums="0" export THING=0 ``` You can also declare multiple variables on one line. -```bash +```bash linenums="0" export THING=0 DATASET=foo.in ``` @@ -255,14 +260,14 @@ export THING=0 DATASET=foo.in There are a couple of "magic" variables which are not like other programming languages. -```bash +```bash linenums="0" echo $RANDOM ``` Will always give you a random value, even if you set it to be something else. -```bash +```bash linenums="0" echo $SECONDS ``` Will print the number of seconds that have passed since the shell has been opened. @@ -297,7 +302,7 @@ done ``` We can now provide this script arguments, and use them in our script! -```bash +```bash linenums="0" $ bash hellonames.sh jake josh jenny You gave me 3 names! The first name is jake @@ -308,15 +313,14 @@ Hello jenny! ### System Variables -There are also special software/shell environment -variables that change the behavior of different -things. +There are also special software/shell environment variables that change the behavior of different things. | Variable | Meaning | |---|---| | `PATH` | Directories containing programs | | `MANPATH` | Directories containing manual pages | | `LD_LIBRARY_PATH` | Directories containing shared libraries | +| `HOME` | Location of your home directory | @@ -345,7 +349,7 @@ alias Negishi='ssh username@negishi.rcac.purdue.edu' Let's go ahead and make that now: -```bash +```bash linenums="0" cd ~ vim .bashrc #or @@ -365,7 +369,7 @@ the two that we are going to talk about are: You can also add variables (like `PATH`) to your login profile. -```bash +```bash linenums="0" export PATH=$PATH:$HOME/bin ``` This will add the newly created `bin` folder in your @@ -383,7 +387,7 @@ home directory. Which would be bad. An alias is a verbatim command substitution that happens on the command line when invoked like a program. Here's one example: -```bash +```bash linenums="0" alias Negishi='ssh username@negishi.rcac.purdue.edu' ``` Instead of typing the command `ssh username@negishi.rcac.purdue.edu` every time you want to log into Negishi, This alias will allow you to instead just type `Negishi`. @@ -401,7 +405,7 @@ an error condition. Often, programs will document the meaning of their different exit status values in their manual page. -```bash hl_lines="4" +```bash hl_lines="4" linenums="0" $ hello Hello, world! @@ -420,7 +424,7 @@ shell. This is opposite of almost everywhere else. -```bash +```bash linenums="0" if command; then echo "Command Succeeded" else @@ -430,13 +434,13 @@ fi As shorthand, you may also see conditionals formatted like this: -```bash +```bash linenums="0" command && echo "Command Succeeded" || echo "Command Failed" ``` Bash also allows us to run several tests against files and variables with true/false outcomes: -```bash +```bash linenums="0" if [[ -d "$SCRATCH" ]]; then echo "Scratch directory exists" fi @@ -485,7 +489,7 @@ Numeric comparisons can be useful when you want to compare values such as counts | Operator | Meaning | Example | |----------|---------|---------| | `&&` | AND | `[[ -f in.txt && -w out.txt ]] && ./process.sh` | -| `||` | OR | `[[ -d "$SCRATCH" ]] || mkdir -p "$SCRATCH"` | +| `||` | OR | `[[ -d "$SCRATCH" || -d "$CLUSTER_SCRATCH"]] && mkdir -p "$SCRATCH"` | | `!` | NOT | `[[ ! -f config.yaml ]] && echo "Missing config"` | ## Loops @@ -493,7 +497,7 @@ Numeric comparisons can be useful when you want to compare values such as counts Lastly, loops are implemented in `bash`, and can be particularly useful for looping over files or arguments. You can use command substitution to loop through files: -```bash +```bash linenums="0" for f in $(ls *.py); do echo "Processing $f" python $f @@ -505,7 +509,7 @@ Processing file3.py ``` You can loop through file arguments with the `$@` variable: -```bash +```bash linenums="0" for name in $@; do echo "Hello $name!" done @@ -517,7 +521,7 @@ Hello jenny! Lastly, you can loop through an array of integers: -```bash +```bash linenums="0" for number in {1..10}; do echo "On $number!" done @@ -534,6 +538,6 @@ On 9! On 10! ``` -There's many more aspects of `bash` that we're not going to talk about here like while loops, functions, and variable substitution. Before we move on, it's important to note that if a command fails, bash will just continue on by default. +There's many more aspects of `bash` that we're not going to talk about here like while loops, functions, and variable substitution. Next section: [Pipes](./pipes.md) \ No newline at end of file diff --git a/docs/workshops/hpc_exchange/week4/job-history.md b/docs/workshops/hpc_exchange/week4/job-history.md index c36756ec..44c02f2e 100644 --- a/docs/workshops/hpc_exchange/week4/job-history.md +++ b/docs/workshops/hpc_exchange/week4/job-history.md @@ -4,7 +4,7 @@ Let's submit a job again with `sbatch` and check on it with `squeue`. -```bash +```bash linenums="0" $ sbatch example.sh Submitted batch job 19823415 @@ -18,7 +18,7 @@ JOBID USER ACCOUNT NAME NODES CPUS TIME_LIMIT ST TIME Notice that the job disappeared from the output of `squeue` after completion. How can we check on jobs after they've disappeared here? If you know the job ID, you can always run `jobinfo`: -```bash +```bash linenums="0" $ jobinfo 19823415 Name : example.sh User : username @@ -36,7 +36,7 @@ But how do we query the full job history? We can use the `sacct` program to search deeper into our job history: -```bash +```bash linenums="0" $ sacct -u username JobID Jobname Partition Account AllocCPUS State ExitCode ------------ ---------- ---------- ---------- ---------- ---------- -------- @@ -69,7 +69,7 @@ The `sacct` program is highly malleable, with many options for data filtering an An example of a job search that is only for a specific username with a specific submission account over the past 15 days would be: -```bash +```bash linenums="0" $ sacct -X -u username -A hpcexc --starttime=now-15days -o JobID,JobName,User,State,Elapsed,NodeList JobID JobName User State Elapsed NodeList diff --git a/docs/workshops/hpc_exchange/week4/multinode-topology.md b/docs/workshops/hpc_exchange/week4/multinode-topology.md index 3fba7564..62df6bb3 100644 --- a/docs/workshops/hpc_exchange/week4/multinode-topology.md +++ b/docs/workshops/hpc_exchange/week4/multinode-topology.md @@ -6,8 +6,8 @@ In jobs, you can also request jobs that span over two or more nodes, these are called **multinode** jobs and have special things to consider when running them. You can request jobs that have different "shapes", such as the layout of the following command: -```bash -sbatch --nodes=2 --ntasks-per-node=2 --cpus-per-task=64... +```bash linenums="0" +sbatch --nodes=2 --ntasks-per-node=2 --cpus-per-task=64 ... ``` Here, the job encompasses two nodes, with two tasks on each node, and 64 cores assigned to each task. The layout looks like this: @@ -33,12 +33,12 @@ srun hostname Distributed workflows rely on application *instances* working together between nodes. Submit your job to the scheduler using the `sbatch` program: -```bash +```bash linenums="0" $ sbatch hostname.sh Submitted batch job 19804935 ``` You can check on the job status using the command `squeue --me`: -```bash +```bash linenums="0" $ squeue --me JOBID USER ACCOUNT NAME NODES CPUS TIME_LIMIT ST TIME 19804935 username lab_queue hostname.sh 2 256 00:10:00 PD 00:00 @@ -46,7 +46,7 @@ JOBID USER ACCOUNT NAME NODES CPUS TIME_LIMIT ST TI If you don't see anything in the output of `squeue --me`, that's because your job already finished. If this happens, use the job ID that was put out by the `sbatch` command. Remember that the job ID will be used for the output filename (e.g. `slurm-19804935.out`). You can use the `cat` program to show the output stored in the file: -```bash +```bash linenums="0" $ cat slurm-19804935.out a200.negishi.rcac.purdue.edu a200.negishi.rcac.purdue.edu diff --git a/docs/workshops/hpc_exchange/week4/storage-transfer.md b/docs/workshops/hpc_exchange/week4/storage-transfer.md index dae2f663..7a9c9b3d 100644 --- a/docs/workshops/hpc_exchange/week4/storage-transfer.md +++ b/docs/workshops/hpc_exchange/week4/storage-transfer.md @@ -79,7 +79,7 @@ It is good for node-local caching of data and files. It is **NOT** for valuable ### Checking Access Reminder that you can use the `myquota` command to check your current usage on local storage locations! -```bash +```bash linenums="0" $ myquota Type Location Size Limit Use Files Limit Use =========================================================================== @@ -114,7 +114,7 @@ Fortress is good for backing up (archiving) critical research data. It is good a To access Fortress and move files to/from it, use the `hsi/htar` programs. -```bash +```bash linenums="0" $ hsi *************************************************************************** ** No Fortress keytab found in your home directory. Creating one now. ** @@ -129,7 +129,7 @@ $ hsi We can use `hsi` to navigate the tape archive system. We can create, remove, rename, and directories "like normal". While in the `hsi` interface, use the `help` program for a listing of commands and what they do. Outside of the `hsi` interface, you can run `hsi help` to get the same information. -```bash +```bash linenums="0" [Fortress HSI]/home/username->ls [Fortress HSI]/home/username->mkdir example @@ -141,7 +141,7 @@ mkdir: /home/username/example Use `put` and `get` to copy data to and from the tape archive. Let's add our directory to the archive and try to get it back. -```bash +```bash linenums="0" [Fortress HSI]/home/username->put -R example-data put 'example-data/paper.txt' : paper.txt ``` @@ -151,14 +151,14 @@ put 'example-data/paper.txt' : paper.txt To exit the `hsi` interface, use the `exit` command. -```bash +```bash linenums="0" [Fortress HSI]/home/username-> exit username@loginXX.CLUSTER:[~] $ ``` You can also use `hsi` commands in one shot without logging in first. Try removing the `example-data` directory from the cluster and then bringing it back with `hsi get`. To be extra safe, we will rename it here instead of actually deleting the directory and its contents. -```bash +```bash linenums="0" $ mv example-data backup $ hsi get -R example-data @@ -175,7 +175,7 @@ Instead of using `hsi` command to get and put files, we shouldn't store all thes ### Transferring data to and from Fortress You can bundle and send the whole directory in one stream with the `htar` program.: -```bash +```bash linenums="0" $ htar -cvf example-data.tar example-data/ HTAR: a example-data/ HTAR: a example-data/paper.txt @@ -223,7 +223,7 @@ echo "Backed up data to Fortress at $(date)!" Once this runs we can check to see the status of the job with `squeue --me`. Once it finishes running, we can check the output file (`example.out`) to make sure it does what we expect. Remember that All the text that would normally print to the terminal (`stdout` and `stderr`) will instead go into the slurm log! -```bash +```bash linenums="0" $ sbatch myjob.sh Submitted batch job 2095574 @@ -245,14 +245,14 @@ Backed up data to Fortress at Wed Jan 28 12:45:49 EST 2026! Notice that this script doesn't contain our python output, because we redirected that output to a file (`> results.out`) and then archived the file with `htar`. There's two places we need to check for the output of our job. First is the `scratch` directory that the python output file was created in: -```bash +```bash linenums="0" $ cat $SCRATCH/example/results.out 2499.9118 ``` Then, we also need to check that our `example.tar` file was created on Fortress: -```bash +```bash linenums="0" $ hsi ls /home/username: example-data/ example-data.tar example.tar diff --git a/docs/workshops/hpc_exchange/week4/utilization-monitoring.md b/docs/workshops/hpc_exchange/week4/utilization-monitoring.md index 02fb120e..3b5cca79 100644 --- a/docs/workshops/hpc_exchange/week4/utilization-monitoring.md +++ b/docs/workshops/hpc_exchange/week4/utilization-monitoring.md @@ -8,7 +8,7 @@ Now that we can check our job history, let's learn how we can check that we are You can use the `jobinfo` program with the ID to see which node your job is on and `ssh` directly there. Let's run our job again -```bash +```bash linenums="0" $ sbatch --exclusive myjob.sh Submitted batch job 19823415 @@ -22,12 +22,12 @@ JOBID USER ACCOUNT NAME NODES CPUS TIME_LIMIT ST TIME Once you've done `jobinfo` to determine which node your job has landed on, you can `ssh` directly to the node. This is something you can do only if you have a Slurm job on the node. Once on the node, use a tool like `htop` to inspect CPU and memory activity (press `q` to quit). -```bash +```bash linenums="0" username@login03.negishi:[~] $ jobinfo 19823415 ... Nodes : a200 ``` -```bash +```bash linenums="0" username@login03.negishi:[~] $ ssh a200 username@a200.negishi:[~] $ top -u username # Or htop @@ -45,7 +45,7 @@ username@a200.negishi:[~] $ top -u username # Or htop However, just `ssh`ing onto the node isn't *real* telemetry. We want to collect and store the data. To do this, we can use the `monitor` utility (which is RCAC specific) to gather data on CPU and GPU metrics. -```bash +```bash linenums="0" $ module load monitor $ monitor cpu memory DATE TIME HOSTNAME monitor.cpu.memory 15.7 @@ -98,13 +98,13 @@ Be sure to ask for all the (with `--exclusive`) on the node so you don't collec The `&` puts the process into the background! If we didn't, the node would be stuck on the monitor command until the walltime ran out. Check out [Managing Processes](../week3/processes.md) from Week 3 if you need a refresher. Now, let's run the new monitored submission file: -```bash +```bash linenums="0" $ sbatch --exclusive example.sh Submitted batch job 2095586 ``` Once it's done, let's look at the output of the files: -```bash +```bash linenums="0" $ cd $SCRATCH/example $ cat cpu_mem.csv DATE, TIME, HOSTNAME, monitor.cpu.memory, 15.7 diff --git a/docs/workshops/hpc_exchange/week4/workload-management.md b/docs/workshops/hpc_exchange/week4/workload-management.md index 74bf8754..02dd6440 100644 --- a/docs/workshops/hpc_exchange/week4/workload-management.md +++ b/docs/workshops/hpc_exchange/week4/workload-management.md @@ -16,7 +16,7 @@ In many cases, researchers need to run the same task multiple times with differe If we want to submit many separate jobs, we could simply run `sbatch` on many different job scripts: -```bash +```bash linenums="0" sbatch job1.sh sbatch job2.sh sbatch job3.sh @@ -25,7 +25,7 @@ sbatch job3.sh Alternatively, if our job script is able to take arguments as input, we could reuse the same job submission script, and just change the input: -```bash +```bash linenums="0" sbatch job.sh input_1 sbatch job.sh input_2 @@ -88,7 +88,7 @@ Notice that we create and work in a different directory in our scratch based on We don't have to submit this one, but to submit it, we would run the `submit.sh` file as a program: -```bash +```bash linenums="0" $ bash ./submit.sh Submitted batch job 209526 Submitted batch job 209527