Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
apt-get install sysstat bc
cp ./ashutdown /usr/local/bin/
cp ./ashutdown.service /lib/systemd/system/
systemctl --no-reload --now enable /lib/systemd/system/ashutdown.service
[Unit]
Description=Auto Shutdown
[Service]
Type=simple
ExecStart=/usr/local/bin/ashutdown
PIDFile=/run/ashutdown.pid
Restart=always
[Install]
#!/bin/bash
# Number of sequential checks when the instance had utilization below the threshold.
COUNTER=0
# If actual CPU utilization is below this threshold script will increase the counter.
THRESHOLD_PERCENT=2
# Interval between checks of the CPU utilizations.
SLEEP_INTERVAL_SECONDS=5
# How big COUNTER need to be for the script to shutdown the instance. For example,
# if we want an instance to be stopped after 20min of idle. Each utilization probe
export INSTANCE_GROUP_NAME="tf-training-cluster"
export INSTANCE_TEMPLATE_NAME="tf-latest-gpu-template"
gcloud compute instance-groups managed create "${INSTANCE_GROUP_NAME}" \
--template "${INSTANCE_TEMPLATE_NAME}" \
--base-instance-name tf-training-cluster \
--size 2 \
--zone us-west1-b
export INSTANCE_TEMPLATE_NAME="tf-latest-gpu-template"
export IMAGE_FAMILY="tf-latest-gpu"
export TRAINING_SCRIPT="wget https://raw.githubusercontent.com/horovod/horovod/v0.16.4/examples/tensorflow_mnist.py"
gcloud compute instance-templates create "${INSTANCE_TEMPLATE_NAME}" \
--machine-type=n1-standard-64 \
--maintenance-policy=TERMINATE \
--accelerator=type=nvidia-tesla-v100,count=8 \
--min-cpu-platform=Intel\ Skylake \
--image-family="${IMAGE_FAMILY}" \
export IMAGE_FAMILY="tf-latest-gpu"
export ZONE="us-west1-b"
export INSTANCE_NAME="my-instance"
export INSTANCE_TYPE="n1-standard-4"
export NETWORK="network-1"
gcloud compute instances create $INSTANCE_NAME \
--zone=$ZONE \
--image-family=$IMAGE_FAMILY \
--machine-type=$INSTANCE_TYPE \
--image-project=deeplearning-platform-release \
export IMAGE_FAMILY="r-latest-cpu-experimental"
export ZONE="us-west1-b"
export INSTANCE_NAME="my-r-instance"
export INSTANCE_TYPE="n1-standard-8"
gcloud compute instances create "${INSTANCE_NAME}" \
--zone="${ZONE}" \
--image-family="${IMAGE_FAMILY}" \
--image-project=deeplearning-platform-release \
--machine-type="${INSTANCE_TYPE}" \
--boot-disk-size=100GB
# These are Cloud Build steps. You can read more about cloud build here:
# https://cloud.google.com/cloud-build/docs/
# All these steps sharing a filesystem between each other.
steps:
# ↓↓↓↓↓↓↓ Start of Continuous Integration Part ↓↓↓↓↓↓↓↓↓↓↓↓ #####
######### This part will test if Notebook fully executable #####
# First, we need to clone the repository that we need to test.
# This will also clone submodules that are used as dependancies.
- name: 'gcr.io/cloud-builders/git'
args: ['clone', '--recurse-submodules', 'https://github.com/b0noI/notebooks-ci-showcase']
#!/bin/bash -u
# Sourcing logic that contains execute_notebook CLI
# This CLI is used to schedule notebooks
# To learn more:
# * original repository: https://github.com/gclouduniverse/gcp-notebook-executor
# * article about it: https://blog.kovalevskyi.com/how-to-submit-jupyter-notebook-for-overnight-training-on-gcp-4ce1b0cd4d0d
source gcp-notebook-executor/utils.sh
# Input values for the test, we only need 2:
# You can use any branch but this article been tested with 0.1.2 only
git clone https://github.com/gclouduniverse/gcp-notebook-executor.git --branch v0.1.2
cd gcp-notebook-executor
source utils.sh
INPUT_NOTEBOOK="./demo.ipynb"
# Should be existing bucket
GCP_BUCKET="gs://b0noi-tmp/test-execution/"
IMAGE_FAMILY_NAME="tf-latest-cpu"