Skip to content

Instantly share code, notes, and snippets.

@richbai90
Last active January 30, 2025 19:26
Show Gist options
  • Save richbai90/ce4a33343a03e8cd35dc332f1741d119 to your computer and use it in GitHub Desktop.
Save richbai90/ce4a33343a03e8cd35dc332f1741d119 to your computer and use it in GitHub Desktop.

Guide to Using the Center for High-Performance Computing (CHPC) at the University of Utah

This guide outlines the workflow for effectively utilizing the CHPC resources at the University of Utah. It covers setting up your environment, connecting to CHPC, managing interactive sessions, and tips for efficient computation.


1. Set Up Your CHPC Account

1.1. Set Bash as Your Default Shell

  1. Log in to the CHPC User Portal:

  2. Change Your Shell:

    • Locate the "Shell in General Environment" option.
    • Select "/bin/bash" from the dropdown menu.
    • Click "Submit" to save your changes.

2. Connect to CHPC via SSH

2.1. SSH Connection Basics

  1. SSH URL Format:

    • Use the following format to connect to CHPC clusters:
      ssh unid@cluster[1,2].chpc.utah.edu
      
      • Replace unid with your University of Utah ID.
      • Replace cluster with the name of the cluster you wish to access (e.g., ash or notch).
      • Optionally, specify 1 or 2 to connect to a specific cluster (e.g., cluster1 or cluster2).
  2. Examples:

    • Connect to the default cluster (load balancer will assign you to the preferred cluster):
      ssh [email protected]
      
    • Connect to a specific cluster (e.g., cluster1):
      ssh [email protected]
      
  3. GUI Alternative:

  4. Windows Users:

    • Enable OpenSSH Client (built into Windows 10 and later).
    • Alternatively, download and use PuTTY or FastX.

3. Add the Interactive Helper Command to Your Profile

3.1. Edit Your Bash Profile

  1. Open the Bash Profile:

    • Use nano to edit your ~/.bashrc file:
      nano ~/.bashrc
      
  2. Add the Interactive Helper Function:

    • Scroll to the bottom of the file and paste the following function:
    interactive ()
    { 
        local DEFAULT_ARGS=(--account="$1" --partition="$2" --nodes=1 --ntasks-per-node=1 --cpus-per-task=4 --mem=64G --time="$3" --gres=gpu:l40s:1);
        local EXTRA_ARGS=();
        for ((i=1; i<=$#; i++))
        do
            if [[ "${!i}" == "--" ]]; then
                EXTRA_ARGS=("${@:((i+1))}");
                break;
            fi;
        done;
        declare -A arg_map;
        for arg in "${DEFAULT_ARGS[@]}";
        do
            key="${arg%%=*}";
            arg_map["$key"]="$arg";
        done;
        for extra_arg in "${EXTRA_ARGS[@]}";
        do
            key="${extra_arg%%=*}";
            arg_map["$key"]="$extra_arg";
        done;
        local final_args=();
        for arg in "${!arg_map[@]}";
        do
            final_args+=("${arg_map[$arg]}");
        done;
        if [ -z ${DEBUG+x} ]; then
            salloc "${final_args[@]}";
        else
            echo "salloc ${final_args[@]}";
        fi
    }
  1. Save and Exit:

    • Press Ctrl + O to save.
    • Press Ctrl + X to exit.
  2. Apply Changes:

    • Reload your Bash profile:
      source ~/.bashrc
      

4. Start a Tmux Session

4.1. Why Use Tmux?

  • Persistent Sessions: Tmux allows you to detach and reattach to your session, making it ideal for long-running jobs.
  • Multiple Windows/ Panes: Tmux supports multiple windows and panes for organizing your workflow.

4.2. Start a New Tmux Session

  1. Create a New Session:

    tmux new -s my_session
    
    • Replace my_session with a meaningful name for your session.
  2. Detach from the Session:

    • Press Ctrl + B, then D to detach.
  3. Reattach to the Session:

    tmux attach -t my_session
    

5. Request an Interactive Session

5.1. Use the Interactive Helper Function

  1. Inside a Tmux Session:

    • Ensure you are inside your tmux session before requesting an interactive session.
  2. Request Resources:

    • Use the interactive function to request an interactive session:
      interactive my_account main_partition 01:00:00
      
      • Replace:
        • my_account with your CHPC account name.
        • main_partition with the partition (queue) you want to use.
        • 01:00:00 with your desired walltime in HH:MM:SS format.
  3. Customize Resource Requests (Optional):

    • Override default arguments by adding extra parameters:
      interactive my_account main_partition 01:00:00 -- --nodes=2 --mem=128G
      
  4. Additonal Usage Instructions (Optional):


6. Detach and Reattach to Your Session

  1. Detach from Tmux Session:

    • Press Ctrl + B, then D to detach from your tmux session.
  2. Reattach Later:

    • Reattach to your session when you are ready to resume work:
      tmux attach -t my_session
      

7. Additional Tips and Resources

7.1. Monitoring Your Job

  • Use squeue -u unid to monitor your job status.
  • Use sacct to view historical job information.

7.2. Accessing Storage

  • Home Directory: /uufs/chpc.utah.edu/common/home/unid
  • Scratch Space: plan to use /scratch for temporary storage.

7.3. Getting Help


By following this guide, you can efficiently utilize CHPC resources for your computational needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment