-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtrainer.sh
73 lines (59 loc) · 2.81 KB
/
trainer.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
INSTANCE='trainer-2'
ZONE='us-central1-c'
function announce() {
echo '=='
echo "- $1"
}
function e() {
echo '=='
echo "Running \`$@\`"
eval $@
echo
}
function gssh() {
E=$1
CHECK="$(check "$2")"
[ -n "$CHECK" ] && E="$CHECK $E"
COMMAND="gcloud compute ssh --zone $ZONE $INSTANCE --project solana-paint -- -C 'bash -lc \"$E\"'"
e $COMMAND
}
function check() {
[ -n "$1" ] && echo "$1 && echo \\\"$1 short-circuited execution\\\" ||" || echo ''
}
announce 'Creating trainer'
e gcloud compute instances create $INSTANCE \
--project=solana-paint \
--zone=$ZONE \
--machine-type=n1-standard-2 \
--network-interface=network-tier=PREMIUM,subnet=default \
--maintenance-policy=TERMINATE \
--service-account=914975206125-compute@developer.gserviceaccount.com \
--scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append \
--accelerator=count=1,type=nvidia-tesla-t4 \
--create-disk=auto-delete=yes,boot=yes,device-name=$INSTANCE,image=projects/ubuntu-os-cloud/global/images/ubuntu-1804-bionic-v20220213,mode=rw,size=200,type=projects/solana-paint/zones/$ZONE/diskTypes/pd-balanced \
--no-shielded-secure-boot \
--shielded-vtpm \
--shielded-integrity-monitoring \
--reservation-affinity=any && \
sleep 30
announce 'Housekeeping'
gssh 'sudo apt-get update --yes && sudo apt-get dist-upgrade --yes'
announce 'Install Python & Pip'
gssh 'sudo apt-get install --yes python3 python3-pip python3-dev python3-setuptools && pip3 install --upgrade pip'
announce 'Install CUDA'
gssh 'curl https://raw.githubusercontent.com/GoogleCloudPlatform/compute-gpu-installation/main/linux/install_gpu_driver.py --output install_gpu_driver.py && sudo python3 install_gpu_driver.py'
announce 'Downloading Pytorch Examples'
gssh 'git clone git@github.com:timeemit/tutorials.git'
announce 'Install Cython'
gssh 'pip3 install cython'
announce 'Install Pillow dependencies'
gssh 'sudo apt-get install --yes libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk libharfbuzz-dev libfribidi-dev libxcb1-dev zip'
announce 'Install Python requirements'
gssh 'pip3 install -r tutorials/requirements.txt'
announce 'Download celeba dataset'
gssh 'make -C ./tutorials download'
gssh 'mkdir -p ./tutorials/data unzip ./tutorials/_data/img_align_celeba.zip -d ./tutorials/data/celeba/'
announce 'Upload emojis dataset'
e gcloud compute scp --zone $ZONE --project solana-paint ./emojis.zip $INSTANCE:~/tutorials/
gssh 'unzip ~/tutorials/emojis.zip -d ~/tutorials/data/'
gssh 'rm -r ~/tutorials/data/image/{DoCoMo,JoyPixels,KDDI,SoftBank}'