arrow_back

Deploy an Auto-Scaling HPC Cluster with Slurm

Join Sign in

Deploy an Auto-Scaling HPC Cluster with Slurm

1 hour 5 Credits

GSP690

Google Cloud selp-paced labs logo

Overview

Google Cloud teamed up with SchedMD to release a set of tools that make it easier to launch the Slurm workload manager on Compute Engine, and to expand your existing cluster dynamically when you need extra resources. This integration was built by the experts at SchedMD in accordance with Slurm best practices.

In this lab you will learn to run a Slurm cluster on Google Cloud. You will learn how to provision and operate an auto-scaling Slurm cluster.

If you're planning on using the Slurm on Google Cloud integrations, or if you have any questions, please consider joining our Google Cloud & Slurm Community Discussion Group!

slurm logo

About Slurm

a739730a41acff0a.png

Basic architectural diagram of a stand-alone Slurm Cluster in Google Cloud.

Slurm is one of the leading workload managers for HPC clusters around the world. Slurm provides an open-source, fault-tolerant, and highly-scalable workload management and job scheduling system for small and large Linux clusters. Slurm requires no kernel modifications for its operation and is relatively self-contained. As a cluster workload manager, Slurm has three key functions:

  1. It allocates exclusive or non-exclusive access to resources (compute nodes) to users for some duration of time so they can perform work.

  2. It provides a framework for starting, executing, and monitoring work (normally a parallel job) on the set of allocated nodes.

  3. It arbitrates contention for resources by managing a queue of pending work.

Objectives

In this lab, you will learn:

  • How to setup up a Slurm cluster using Terraform
  • How to run a job using SLURM
  • How to query cluster information and monitor running jobs in SLURM
  • How to autoscale nodes to accommodate specific job parameters and requirements
  • Where to find help with Slurm

Setup and Requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab---remember, once you start, you cannot pause a lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

How to start your lab and sign in to the Google Cloud Console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:

    • The Open Google Console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information, if needed, to step through this lab
  2. Click Open Google Console. The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username from the Lab Details panel and paste it into the Sign in dialog. Click Next.

  4. Copy the Password from the Lab Details panel and paste it into the Welcome dialog. Click Next.

    Important: You must use the credentials from the left panel. Do not use your Google Cloud Skills Boost credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  5. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Cloud Console opens in this tab.

Note: You can view the menu with a list of Google Cloud Products and Services by clicking the Navigation menu at the top-left. Navigation menu icon

Prepare and Review Slurm Terraform Configuration

Download the Slurm Terraform Configuration

In the Cloud Shell session, execute the following command to clone (download) the Git repository that contains the Slurm for Google Cloud Platform Terraform files:

git clone https://github.com/SchedMD/slurm-gcp.git

Switch to the Slurm deployment configuration directory by executing the following command:

cd slurm-gcp

Configure Slurm Terraform tfvars

The basic.tfvars.example file details the configuration of the deployment, including the network, instances, and storage to deploy. Copy it to a new file, which you’ll call “the tfvars file”, then edit as needed.

cd tf/examples/basic cp basic.tfvars.example basic.tfvars

In the Cloud Shell session, open the tfvars file basic.tfvars. You can either use your preferred command line editor (vi, nano, emacs, etc.) or use the Cloud Console Code Editor to view the file contents:

open-editor.png

Review the contents of the basic.tfvars file:

cluster_name = "g1" project = "" zone = "us-central1-a" # network_name = "" # subnetwork_name = "" # shared_vpc_host_project = "" # disable_controller_public_ips = true # disable_login_public_ips = true # disable_compute_public_ips = true # suspend_time = 300 controller_machine_type = "n1-standard-2" controller_image = "projects/schedmd-slurm-public/global/images/family/schedmd-slurm-20-11-7-hpc-centos-7" controller_disk_type = "pd-standard" controller_disk_size_gb = 50 # controller_labels = { # key1 = "val1" # key2 = "val2" # } # controller_service_account = "default" # controller_scopes = ["https://www.googleapis.com/auth/cloud-platform"] # cloudsql = { # server_ip = "" # user = "slurm" # password = "verysecure" # db_name = "slurm_accounting" # } # controller_secondary_disk = false # controller_secondary_disk_size = 100 # controller_secondary_disk_type = "pd-ssd" # # When specifying an instance template, specified controller fields will # override the template properties. # controller_instance_template = null login_machine_type = "n1-standard-2" login_image = "projects/schedmd-slurm-public/global/images/family/schedmd-slurm-20-11-7-hpc-centos-7" login_disk_type = "pd-standard" login_disk_size_gb = 20 # login_labels = { # key1 = "val1" # key2 = "val2" # } # login_node_count = 1 # login_node_service_account = "default" # login_node_scopes = [ # "https://www.googleapis.com/auth/monitoring.write", # "https://www.googleapis.com/auth/logging.write" # ] # # When specifying an instance template, specified login fields will # override the template properties. # login_instance_template = null # Optional network storage fields # network_storage is mounted on all instances # login_network_storage is mounted on controller and login instances # network_storage = [{ # server_ip = "" # remote_mount = "/home" # local_mount = "/home" # fs_type = "nfs" # mount_options = null # }] # # login_network_storage = [{ # server_ip = "" # remote_mount = "/net_storage" # local_mount = "/shared" # fs_type = "nfs" # mount_options = null # }] # compute_node_service_account = "default" # compute_node_scopes = [ # "https://www.googleapis.com/auth/monitoring.write", # "https://www.googleapis.com/auth/logging.write" # ] partitions = [ { name = "debug" machine_type = "c2-standard-4" static_node_count = 0 max_node_count = 10 zone = "us-central1-a" image = "projects/schedmd-slurm-public/global/images/family/schedmd-slurm-20-11-7-hpc-centos-7" image_hyperthreads = true compute_disk_type = "pd-standard" compute_disk_size_gb = 20 compute_labels = {} cpu_platform = null gpu_count = 0 gpu_type = null network_storage = [] preemptible_bursting = false vpc_subnet = null exclusive = false enable_placement = false regional_capacity = false regional_policy = {} instance_template = null }, # { name = "partition2" # machine_type = "c2-standard-16" # static_node_count = 0 # max_node_count = 20 # zone = "us-central1-a" # image = "projects/schedmd-slurm-public/global/images/family/schedmd-slurm-20-11-7-hpc-centos-7" # image_hyperthreads = true # # compute_disk_type = "pd-ssd" # compute_disk_size_gb = 20 # compute_labels = { # key1 = "val1" # key2 = "val2" # } # cpu_platform = "Intel Skylake" # gpu_count = 8 # gpu_type = "nvidia-tesla-v100" # network_storage = [{ # server_ip = "none" # remote_mount = "" # local_mount = "/data" # fs_type = "gcsfuse" # mount_options = "file_mode=664,dir_mode=775,allow_other" # }] # preemptible_bursting = true # vpc_subnet = null # exclusive = false # enable_placement = false # # # With regional_capacity : true, the region can be specified in the zone. # # Otherwise the region will be inferred from the zone. # zone = "us-central" # regional_capacity = true # # Optional # regional_policy = { # locations = { # "zones/us-central-a" = { # preference = "DENY" # } # } # } # # # When specifying an instance template, specified compute fields will # # override the template properties. # instance_template = "my-template" # } ]

Replace <project> with your Qwiklabs Project ID for the value of the project field. You can copy this value from panel on your lab instructions page.

Within this tfvars file there are several fields to configure. The only field that must be configured is the project. All other configurations in the example can be used as is, but modify them as required for your situation. For a more detailed description of the configurations options, see here.

  • cluster_name: Name of the Slurm cluster

  • project: Google Cloud Project ID for where resources will be deployed

  • zone: Google Cloud zone which will contain the controller and login instances of this cluster - More Info

  • network_name: Virtual Private Cloud network to deploy the Slurm cluster into

  • subnetwork_name: Virtual Private Cloud subnetwork to deploy the Slurm cluster into

  • shared_vpc_host_project: Shared VPC network to deploy the Slurm cluster into

  • disable_controller_public_ips: Assign external IP to the Slurm controller?

  • disable_login_public_ips: Assign external IP to the Slurm login node?

  • disable_compute_login_ips: Assign external IP to the Slurm login node?

  • suspend_time: Time to wait after a node is idle before suspending the node

  • controller_machine_type: Controller node instance type

  • controller_image: GCP image used to create the Slurm controller instance

  • controller_disk_type: Type of the controller instance boot disk

  • controller_disk_size_gb: Size of a controller instance boot disk

  • controller_labels: Label(s) to attach to the controller instance

  • controller_service_account: Service account to be used on the controller instance

  • controller_scopes: Access scope of the controller instance

  • cloudsql: Google CloudSQL server to use as the Slurm database instead of hosting a database on the controller instance

    • server_ip: CloudSQL server IP
    • user: CloudSQL username
    • password: CloudSQL password
    • db_name: CloudSQL database name
  • controller_secondary_disk: Add a secondary disk for NFS server storage?

  • controller_secondary_disk_type: Type of the controller secondary disk

  • controller_secondary_disk_size_gb: Size of the controller secondary disk

  • controller_instance_template: The GCP instance template to use for the controller instance. Any compute fields specified will override the template properties. Eg. if controller_image is specified, it will overwrite the image in the instance template.

  • login_machine_type: Login (SSH-accessible) node instance type

  • login_image: GCP image used to create the Slurm login instance

  • login_disk_type: Type of the login instance boot disk

  • login_disk_size_gb: Size of the login instance boot disk

  • login_labels: Label(s) to attach to the login instance

  • login_node_count: Number of login nodes to create

  • login_node_service_account: Service account to be used on the login instance(s)

  • login_node_scopes: Access scope of the login instance

  • login_instance_template: The GCP instance template to use for the login instance. Any compute fields specified will override the template properties. Eg. if login_image is specified, it will overwrite the image in the instance template.

  • network_storage: Network storage to mount on all nodes. Fields will be added directly to fstab. Can be repeated for additional mounts.

    • server_ip: Storage server IP
    • remote_mount: Storage mount name (filesystem name)
    • local_mount: Local mount directory
    • fs_type: Filesystem type (NFS, CIFS, Lustre, GCSFuse installed automatically)
    • mount_options: Mount options (i.e. defaults,_netdev)
  • login_network_storage: Network storage to mount on login and controller nodes. NFS, CIFS, Lustre, and GCSFuse will be installed automatically. Can be repeated for additional mounts.

    • server_ip: Storage server IP
    • remote_mount: Storage mount name (filesystem name)
    • local_mount: Local mount directory
    • fs_type: Filesystem type (NFS, CIFS, Lustre, GCSFuse installed automatically)
    • mount_options: Mount options (i.e. defaults,_netdev)
  • compute_node_service_account: Service account to be used on the compute instance(s)

  • compute_node_scopes: Access scope of the compute instances

  • partitions: Slurm partition configuration. Can be repeated for additional partitions.

    • name: Partition name
    • machine_type: Compute node(s) instance type
    • static_node_count: Number of always-on compute nodes
    • max_node_count: Maximum number of total compute nodes allowed - 64K maximum
    • zone: Google Cloud zone which will contain the resources of this partition - More Info
    • image: Compute image node machine type
    • image_hyperthreads: Turn on or off hyperthreading on the instance
    • compute_disk_type: Type of a compute instance boot disk (pd-standard, pd-ssd)
    • compute_disk_size_gb: Size of a compute instance boot disk
    • compute_labels: Label(s) to attach to the compute instance
    • cpu_platform: Minimum CPU platform required for all compute nodes
    • gpu_count: Number of GPUs to attach to each instance in the partition
    • gpu_type: GPU type to attach to the partition’s instances
    • network_storage: Network storage to mount on all compute nodes in the partition. Fields will be added directly to fstab. Can be repeated for additional mounts.
      • server_ip: Storage server IP
      • remote_mount: Storage mount name (filesystem name)
      • local_mount: Local mount directory
      • fs_type: Filesystem type (NFS, CIFS, Lustre, GCSFuse installed automatically)
      • mount_options: Mount option
    • preemptible_bursting: Will the instances be preemptible instances?
    • vpc_subnet: Virtual Private Cloud subnetwork to deploy the Slurm partition into
    • exclusive: Enable Slurm to allocate entire nodes to jobs
    • enable_placement: Enable placement policies where instances will be located close to each other for low network latency between the instances.
    • regional_capacity: Allow an instance to be placed in any zone in the region based on availability
    • regional_policy: If regional_capacity is true, this policy is to determine what region to use and any zones in that region not to use
    • Instance_template: The GCP instance template to use for compute instances. Any compute fields specified will override the template properties. Eg. if image is specified, it will overwrite the image in the instance template.

Advanced Configuration

If desired you may choose to install additional packages and software as part of the cluster deployment process. You can install software on your slurm cluster in multiple ways outlined in our "Installing apps in a Slurm cluster on Compute Engine", or by customizing the image deployed by Slurm. Currently Slurm deploys a SchedMD-provided VM Image that’s based on the Google Cloud HPC VM Image, with Slurm installed on top of it.

In order to use your own image, build an image with your own configuration based on the public SchedMD VM Image listed in the tfvars file. Next, replace the image URI specified in the tfvars file with your own image, and test the change.

Deploying and verifying the configuration

Deploy the Configuration

In the Cloud Shell session, execute the following command from the slurm-gcp/tf/examples folder:

terraform init terraform apply -var-file=basic.tfvars

You will be prompted to accept the actions described, based on the configurations that’s been set. Enter “yes” to begin the deployment. You can also view the configuration to be deployed by running “terraform plan”.

Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: yes

The operation can take a few minutes to complete. Wait for it to complete before moving on.

Once the deployment has completed you will see output similar to:

Apply complete! Resources: 8 added, 0 changed, 0 destroyed. Outputs: controller_network_ips = [ [ "10.0.0.2", ], ] login_network_ips = [ [ "10.0.0.3", ], ]

Click Check my progress to verify the objective. Deploy the terraform configuration

Verify VM instance creation

Open the navigation menu and select Compute Engine > VM Instances.

You should see a controller and a login VM instance listed:

68d821719e26e6a7.png

Under VM instances review the two virtual machine instances that have been created by Terraform. The names will be different if you modified the cluster_name field.

  • g1-controller
  • g1-login0

The g1-compute-0-image instance is only online for a short time to create the compute image used by the partition’s auto-scaling nodes, and then it is shut down. If you’d like to make updates to the image used by compute nodes you can start this instance, make changes, and make another image in the Slurm cluster’s image family to update that partition’s image.

Login to the Slurm Cluster

Access the Slurm Cluster

Return to your Code Editor/Cloud Shell tab. Run the following command to login to your instance:

gcloud compute ssh g1-login0 --zone=us-central1-a Note: If g1-login0 is not found in the previous command. Substitute the zone for the zone your g1-login0 node is located in.

This command will log you into the g1-login0 virtual machine.

If this is the first time you have used cloud shell, you may see a message like the one below asking you to create an SSH key:

WARNING: The public SSH key file for gcloud does not exist. WARNING: The private SSH key file for gcloud does not exist. WARNING: You do not have an SSH key for gcloud. WARNING: SSH keygen will be executed to generate a key. This tool needs to create the directory [/home/user/.ssh] before being able to generate SSH keys. Do you want to continue (Y/n)?

If so, enter Y. If requested to select a passphrase, leave it blank by pressing Enter twice.

If the following message appears upon login:

*** Slurm is currently being installed/configured in the background. *** A terminal broadcast will announce when installation and configuration is complete. /home on the controller will be mounted over the existing /home. Any changes in /home will be hidden. Please wait until the installation is complete before making changes in your home directory.

Wait and do not proceed with the lab until you see this message (approx 5 mins):

*** Slurm login setup complete ***

Once you see the above message, you will have to log out and log back in to g1-login0 to continue the lab. To do so, press CTRL + C to end the task.

Then execute the following command to logout of your instance:

exit

Now, reconnect to your login VM:

gcloud compute ssh g1-login0 --zone=us-central1-a

Tour of the Slurm CLI Tools

You're now logged in to your cluster's Slurm login node. This is the node that's dedicated to user/admin interaction, scheduling Slurm jobs, and administrative activity.

Let's run a couple commands to introduce you to the Slurm command line.

Execute the sinfo command to view the status of our cluster's resources:

sinfo

Sample output of sinfo appears below. sinfo reports the nodes available in the cluster, the state of those nodes, and other information like the partition, availability, and any time limitation imposed on those nodes.

PARTITION AVAIL TIMELIMIT NODES STATE NODELIST debug* up infinite 10 idle~ g1-compute-0-[0-9]

You can see our 10 nodes, dictated by the debug partition’s “max_node_count” of 10, are marked as “idle~” (the node is in an idle and non-allocated mode, ready to be spun up).

Next, execute the squeue command to view the status of your cluster's queue:

squeue

The expected output of squeue appears below. squeue reports the status of the queue for a cluster. This includes the job ID of each job scheduled on the cluster, the partition the job is assigned to, the name of the job, the user that launched the job, the state of the job, the wall clock time the job has been running, and the nodes that job is allocated to. You don’t have any jobs running, so the contents of this command is empty.

JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)

The Slurm commands “srun” and “sbatch” are used to run jobs that are put into the queue. “srun” runs parallel jobs, and can be used as a wrapper for mpirun. “sbatch” is used to submit a batch job to slurm, and can call srun once or many times in different configurations. “sbatch” can take batch scripts, or can be used with the --wrap option to run the entire job from the command line.

Run a job so you can see Slurm in action and get a job in our queue!

Run a Slurm Job and Scale the Cluster

Now that you have our Slurm cluster running, let’s run a job and scale our cluster up.

While logged in to g1-login0, use your preferred text editor to create a new file "hostname_batch":

sbatch -N2 --wrap="srun hostname"

This command runs the Slurm batch command. It specifies that sbatch will run 2 nodes with the “-N” option. It also specifies that each of those nodes will run an “srun hostname” command in the “--wrap” option.

By default, sbatch will write it’s output to “slurm-%j.out” in the working directory the command is run from, where %j is substituted for the Job ID according to the Slurm Filename Patterns. In our example sbatch is being run from the user’s /home folder, which is a NFS-based shared file system hosted on the controller by default. This allows compute nodes to share input and output data if desired. In a production environment, the working storage should be separate from the /home storage to avoid performance impacts to the cluster operations. Separate storage mounts can be specified in the tfvars file in the “network_storage” options.

After executing the sbatch script using the sbatch command line it will return a Job ID for the scheduled job, for example:

sbatch hostname_batch

Running sbatch will return a Job ID for the scheduled job, for example:

Submitted batch job 2

You can use the Job ID returned by the sbatch command to track and manage the job execution and resources.

Execute the following command to view the Slurm job queue:

squeue

You will likely see the job you executed listed like below:

JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON) 2 debug hostname student- CF 1:07 2 g1-compute-0-[0-1]

Since you didn’t have any compute nodes provisioned, Slurm will automatically create compute instances according to the job requirements. The automatic nature of this process has two benefits.

First, it eliminates the work typically required in a HPC cluster of manually provisioning nodes, configuring the software, integrating the node into the cluster, and then deploying the job. Second, it allows users to save money because idle, unused nodes are scaled down until the minimum number of nodes is running.

You can also execute the sinfo command to view the Slurm cluster info:

sinfo

This will show the nodes listed in squeue in the “idle” state, meaning the nodes are being created:

PARTITION AVAIL TIMELIMIT NODES STATE NODELIST debug* up infinite 8 idle~ g1-compute-0-[2-9] debug* up infinite 2 idle g1-compute-0-[0-1]

You can also check the VM instances section in Cloud Console to view the newly provisioned nodes. It will take a few minutes to spin up the nodes and get Slurm installed before the job is allocated to the newly allocated nodes. Your VM instances list will soon resemble the following:

vm-instances.png

Once the nodes are running the job the instances will move to an “alloc” state, meaning the jobs are allocated to a job:

PARTITION AVAIL TIMELIMIT NODES STATE NODELIST debug* up infinite 8 idle~ g1-compute-0-[2-9] debug* up infinite 2 alloc g1-compute-0-[0-1]

Once a job is complete, it will no longer be listed in squeue, and the “alloc” nodes in sinfo will return to the “idle” state. Run “squeue” periodically until the job is completed, after a minute or two.

The output file slurm-%j.out will have been written to your NFS-shared /home folder, and will contain the hostnames. Open or cat the output file (typically slurm-2.out), it contents of the output file will contain:

g1-compute-0-0 g1-compute-0-1

Great work, you’ve run a job and scaled up your Slurm cluster!

Click Check my progress to verify the objective. Run a Slurm Job

Run an MPI Job

Now let’s run an MPI job across our nodes. While logged in to g1-login0, use curl to download an MPI program written in the C programming language:

curl -o https://raw.githubusercontent.com/mpitutorial/mpitutorial/gh-pages/tutorials/mpi-hello-world/code/mpi_hello_world.c

To use OpenMPI tools you need to to load the OpenMPI modules by running this command:

module load openmpi

Use the mpicc tool to compile the MPI C code. Execute the following command:

mpicc mpi_hello_world.c -o mpi_hello_world

This compiles our C code to machine code so that you can run the code across our cluster through Slurm.

Next, use your preferred text editor to create a sbatch script called “helloworld_batch”:

vi helloworld_batch

Type i to enter the vi insert mode.

Copy and paste the following text into the file to create a simple sbatch script:

#!/bin/bash # #SBATCH --job-name=hello_world #SBATCH --output=hello_world-%j.out # #SBATCH --nodes=2 srun mpi_hello_world

Save and exit the code editor by pressing escape and typing “:wq” without quotes.

This script defines the Slurm batch execution environment and tasks. First, the execution environment is defined as bash. Next, the script defines the Slurm options first with the “#SBATCH” lines. The job name is defined as “hello_world”.

The output file is set as “hello_world-%j.out” where %j is substituted for the Job ID according to the Slurm Filename Patterns. This output file is written to the directory the sbatch script is run from. In our example this is the user’s /home folder, which is a NFS-based shared file system. This allows compute nodes to share input and output data if desired. In a production environment, the working storage should be separate from the /home storage to avoid performance impacts to the cluster operations.

Finally, the number of nodes this script should run on is defined as 2.

After the options are defined the executable commands are provided. This script will run the mpi_hello_world code in a parallel manner using the srun command, which is a drop-in replacement for the mpirun command.

Then execute the sbatch script using the sbatch command line:

sbatch helloworld_batch

Running sbatch will return a Job ID for the scheduled job, for example:

Submitted batch job 3

This will run the hostname command across 2 nodes, with one task per node, as well as printing the output to the hello_world-3.out file.

Since you had 2 nodes already provisioned this job will run quickly.

Monitor squeue until the job has completed and no longer listed:

squeue

Once completed open or cat the hello_world-3.out file and confirm it ran on g1-compute-0-[0-1]:

cat hello_world-3.out

Expected output:

Hello, world, I am 0 of 2, (Open MPI v3.1.7a1, package: Open MPI root@g1-controller Distribution, ident: 3.1.7a1, repo rev: v3.1.6-8-g6e2efd3, Unreleased developer copy, 141) Hello, world, I am 1 of 2, (Open MPI v3.1.7a1, package: Open MPI root@g1-controller Distribution, ident: 3.1.7a1, repo rev: v3.1.6-8-g6e2efd3, Unreleased developer copy, 141)

After being idle for 5 minutes (configurable with the YAML’s suspend_time field, or slurm.conf’s SuspendTime field) the dynamically provisioned compute nodes will be de-allocated to release resources. You can validate this by running sinfo periodically and observing the cluster size fall back to 0:

JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON) 2 debug hello_wo username R 0:10 2 g1-compute-0-[0-1]

Click Check my progress to verify the objective. Run an MPI Job

Clean Up the Terraform Deployment

Logout of the slurm node by running this command:

exit

Let any auto-scaled nodes scale down before deleting the deployment. You can also delete these nodes manually by running “gcloud compute instances delete ” for each instance, or by using the Console GUI to select multiple nodes and clicking “Delete”.

You can easily clean up the Terraform deployment after you’re done by executing the following command from your Google Cloud Shell, after logging out of g1-login0:

cd ~/slurm-gcp/tf/examples/basic terraform destroy -var-file=basic.tfvars

When prompted, type yes to continue. This operation can take some time.

What was covered

  • How to use deploy Slurm on GCP using Terraform.

  • How to run a job using Slurm on GCP.

  • How to query cluster information and monitor running jobs in Slurm.

  • How to autoscale nodes with Slurm on GCP to accommodate specific job parameters and requirements.

  • How to compile and run MPI applications on Slurm on GCP.

Congratulations!

Congratulations, you’ve created a Slurm cluster on Google Cloud Platform and used its latest features to auto-scale your cluster to meet workload demand! You can use this model to run any variety of jobs, and it scales to hundreds of instances in minutes by simply requesting the nodes in Slurm.

If you would like to continue learning to use Slurm on Google Cloud, be sure to continue with the "Building Federated HPC Clusters with Slurm" lab. This lab will guide you through setting up two federated Slurm clusters in the cloud, to represent how you might achieve a multi-cluster federation, whether on-premise or in the cloud.

Are you building something cool using Slurm's new Google Cloud-native functionality? Have questions? Have a feature suggestion? Reach out to the Google Cloud team today through Google Cloud's High Performance Computing Solutions website, or chat with us in the Google Cloud & Slurm Discussion Group!

Find Slurm support

If you need support using these integrations in testing or production environments please contact SchedMD directly using their contact page here: https://www.schedmd.com/contact.php

You may also use SchedMD's Troubleshooting guide here: https://slurm.schedmd.com/troubleshoot.html

Finally you may also post your question to the Google Cloud & Slurm Discussion Group found here: https://groups.google.com/forum/#!forum/google-cloud-slurm-discuss

Next Steps / Learn More

Google Cloud Links

Slurm Links

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated December 21, 2021
Lab Last Tested October 19, 2021

Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.