-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathcreate_vm_openmp.sh
executable file
·46 lines (35 loc) · 1.36 KB
/
create_vm_openmp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
REGION=us-west1
ZONE=us-west1-b
NAME=omp
# Config zone.
gcloud config set compute/zone ${ZONE}
# Create GPU instance.
gcloud compute instances create ${NAME} \
--machine-type n1-highcpu-8 \
--image-family ubuntu-1604-lts --image-project ubuntu-os-cloud \
--maintenance-policy TERMINATE --restart-on-failure \
--metadata startup-script='#!/bin/bash
# Determine whether or not we are first-time logging in by existence of g++
if ! dpkg-query -W g++; then
# Disable ssh
service ssh stop
# Install make and g++
apt-get update
apt-get install make gcc g++ -y
# Install ruby and rmate
apt install ruby -y && gem install rmate
# Setup auto shutdown
wget -O /bin/auto_shutdown.sh https://raw.githubusercontent.com/stanford-cme213/stanford-cme213.github.io/master/gcp/auto_shutdown.sh
chmod +x /bin/auto_shutdown.sh
wget -O /etc/init.d/auto_shutdown https://raw.githubusercontent.com/stanford-cme213/stanford-cme213.github.io/master/gcp/auto_shutdown
chmod +x /etc/init.d/auto_shutdown
update-rc.d auto_shutdown defaults
update-rc.d auto_shutdown enable
service auto_shutdown start
# Enable ssh
service ssh start
fi
'
echo "Installing necessary libraries. You will be able to log into the VM after several minutes with:
gcloud compute ssh ${NAME}"