Skip to content

Instantly share code, notes, and snippets.

Activate virtualenvs with python

  1. Install Virtualenvwrapper - this is my favorite way of creating virtualenvs
sudo apt-get install virtualenvwrapper
  1. Install on the compute as well, where 4 is the number of compute nodes:
@sean-smith
sean-smith / python-3-10.md
Last active January 30, 2024 17:50
Python 3.10 on Hyperpods

Ubuntu 20.04

  1. Create a script install-python.sh with the following content:
#!/bin/bash

sudo apt update 
sudo apt upgrade -y
sudo apt install software-properties-common -y 

Switch Enroot to NVME

  1. Create a file enroot_nvme.sh:
#!/bin/bash

# Change the /etc/enroot/enroot.conf file to use local nvme storage:
#ENROOT_RUNTIME_PATH        /tmp/enroot/user-$(id -u) -> /opt/dlami/nvme/enroot/user-$(id -u)
#ENROOT_CONFIG_PATH         ${HOME}/enroot
#ENROOT_CACHE_PATH          /opt/enroot
@sean-smith
sean-smith / instance-id-slurm.md
Last active March 13, 2024 18:29
Get instance ID to hostname mapping from a Slurm job.

Slurm Get Instance ID to Hostname

Update: you only need the following:

mpirun -N 1 -n 2 bash -c 'echo $(hostname): $(cat /sys/devices/virtual/dmi/id/board_asset_tag | tr -d " ")'
  1. Create a file get-instance-id.sh:
@sean-smith
sean-smith / enroot_pyxis.sh
Last active January 3, 2024 00:10
Installs Enroot and Pyxis (+optional hooks) on ParallelCluster
#!/bin/bash
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
# with the License. A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and

Run out of EBS space on an ec2 instance?

  1. Make sure the instance has arn:aws:iam::aws:policy/AmazonEC2FullAccess permissions.

  2. Create a script called resize.sh with the following contents:

#!/bin/bash

# Specify the desired volume size in GiB as a command line argument. If not specified, default to 20 GiB.
SIZE=${1:-20}
@sean-smith
sean-smith / pcluster-ssh.md
Last active November 8, 2023 08:02
Easily SSH into your cluster

ParallelCluster Easy SSH

All credit to @tpbrown for this solution.

Usage:

ssh clustername

Disable Protected Mode in AWS ParallelCluster

If your cluster tries 10 times to launch instances and fails, it'll automatically go into PROTECTED mode. This disables instance provisioning until the compute fleet is restarted.

You'll see inact as the status of the queue when the cluster is in PROTECTED mode:

[ec2-user@ip-10-0-0-98 ~]$ sinfo
PARTITION AVAIL  TIMELIMIT  NODES  STATE NODELIST
default* inact infinite 2 idle~ spot-dy-compute-[1-100]
@sean-smith
sean-smith / cost-monitoring.md
Created April 12, 2023 19:09
Activate cost allocation tags and check on the status of them programatically

Activate AWS Tags in Cost Explorer

CLI

aws ce update-cost-allocation-tags-status —cost-allocation-tags-status="TagKey='parallelcluster:cluster-name',Status='activate'"
aws ce list-cost-allocation-tags --tag-keys='parallelcluster:cluster-name'
{
    "CostAllocationTags": [
        {
@sean-smith
sean-smith / remove-bucket.sh
Last active February 14, 2023 20:01
BE CAREFUL. This removes buckets with the prefix you specify.
#!/bin/bash
# Usage: bash remove-bucket.sh bucket1
for bucket in $(aws s3 ls | grep $1 | awk '{ print $3}'); do
echo "Deleting ${bucket}..."
aws s3 rm --recursive s3://${bucket};
aws s3 rb --force s3://${bucket};
done