Created
March 13, 2019 17:12
-
-
Save TrigonaMinima/e5788304ce8aca7f091ba919eaaa275a to your computer and use it in GitHub Desktop.
Scripts to automate parts of GCP instance management
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export PROJECT_NAME="your_project_name" | |
echo "Selected project - "$PROJECT_NAME | |
gcloud config set project $PROJECT_NAME | |
export IMAGE_FAMILY="pytorch-latest-gpu" # or "pytorch-latest-cpu" for non-GPU instances | |
export ZONE="us-west2-b" # budget: "us-west1-b" | |
export INSTANCE_NAME="your-instance-name" | |
export INSTANCE_TYPE="n1-highmem-8" # budget: "n1-highmem-4" | |
# budget: 'type=nvidia-tesla-k80,count=1' | |
gcloud compute instances create $INSTANCE_NAME \ | |
--zone=$ZONE \ | |
--image-family=$IMAGE_FAMILY \ | |
--image-project=deeplearning-platform-release \ | |
--maintenance-policy=TERMINATE \ | |
--accelerator="type=nvidia-tesla-p4,count=1" \ | |
--machine-type=$INSTANCE_TYPE \ | |
--boot-disk-size=200GB \ | |
--metadata="install-nvidia-driver=True" \ | |
--preemptible |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export PROJECT_NAME="your_project_name" | |
echo "Selected project - "$PROJECT_NAME | |
gcloud config set project $PROJECT_NAME | |
export INSTANCE_NAME="your-instance-name" | |
export ZONE="us-west2-b" # budget: "us-west1-b" | |
echo "Logging in..." | |
gcloud compute ssh --zone=$ZONE jupyter@$INSTANCE_NAME -- -L 8080:localhost:8080 | |
echo "Jupyter instance available at localhost:8080/tree" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export PROJECT_NAME="your_project_name" | |
echo "Selected project - "$PROJECT_NAME | |
gcloud config set project $PROJECT_NAME | |
export INSTANCE_NAME="your-instance-name" | |
export ZONE="us-west2-b" # budget: "us-west1-b" | |
echo "Starting..." | |
gcloud compute instances start --zone=$ZONE $INSTANCE_NAME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export PROJECT_NAME="your_project_name" | |
echo "Selected project - "$PROJECT_NAME | |
gcloud config set project $PROJECT_NAME | |
export INSTANCE_NAME="your-instance-name" | |
export ZONE="us-west2-b" # budget: "us-west1-b" | |
echo "Stopping..." | |
gcloud compute instances stop --zone=$ZONE $INSTANCE_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment