-
Notifications
You must be signed in to change notification settings - Fork 5
/
ann_benchmark_quantization_gcp.sh
executable file
·48 lines (40 loc) · 1.85 KB
/
ann_benchmark_quantization_gcp.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
#!/bin/bash
set -e
ZONE=${ZONE:-"us-central1-a"}
MACHINE_TYPE=${MACHINE_TYPE:-"n2-standard-8"}
export CLOUD_PROVIDER="gcp"
export OS="ubuntu-2204-lts"
instance="benchmark-$(uuidgen | tr [:upper:] [:lower:])"
gcloud compute instances create $instance \
--image-family=$OS --image-project=ubuntu-os-cloud \
--machine-type=$MACHINE_TYPE --zone $ZONE
function cleanup {
gcloud compute instances delete $instance --quiet --zone $ZONE
}
trap cleanup EXIT
# Busy loop to wait for SSH to be ready with a timeout of 5 minutes
echo "Waiting for SSH to be ready..."
SECONDS=0
timeout=300
while [ $SECONDS -lt $timeout ]; do
if gcloud compute ssh --zone $ZONE $instance --command="echo SSH is ready" &>/dev/null; then
break
fi
echo "SSH not ready, retrying in 5 seconds..."
sleep 5
SECONDS=$((SECONDS + 5))
done
if [ $SECONDS -ge $timeout ]; then
echo "Timeout: VM is not SSH'able after 300 seconds"
exit 1
fi
gcloud compute scp --zone $ZONE --recurse install_docker_ubuntu.sh "$instance:~"
gcloud compute ssh --zone $ZONE $instance -- 'sh install_docker_ubuntu.sh'
gcloud compute ssh --zone $ZONE $instance -- 'sudo sudo groupadd docker; sudo usermod -aG docker $USER'
gcloud compute ssh --zone $ZONE $instance -- "mkdir -p ~/apps/"
gcloud compute scp --zone $ZONE --recurse apps/ann-benchmarks "$instance:~/apps/"
gcloud compute scp --zone $ZONE --recurse apps/weaviate-no-restart-on-crash/ "$instance:~/apps/"
gcloud compute scp --zone $ZONE --recurse ann_benchmark_quantization.sh "$instance:~"
gcloud compute ssh --zone $ZONE $instance -- "DATASET=$DATASET DISTANCE=$DISTANCE REQUIRED_RECALL=$REQUIRED_RECALL QUANTIZATION=$QUANTIZATION WEAVIATE_VERSION=$WEAVIATE_VERSION MACHINE_TYPE=$MACHINE_TYPE CLOUD_PROVIDER=$CLOUD_PROVIDER OS=$OS bash ann_benchmark_quantization.sh"
mkdir -p results
gcloud compute scp --zone $ZONE --recurse "$instance:~/results/*.json" results/