generated from ashleve/lightning-hydra-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_job.sh
executable file
·59 lines (47 loc) · 1.65 KB
/
create_job.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
#!/bin/sh
## =====you should change below before creating job======
region="" # project ID of Vertex AI
gcp_project="" # project ID of GCP
## =====you can change below before creating job======
config_file="vertex_ai/configs/hparams_tuning/default.yaml" # the path of config file
git_hash=$(git rev-parse HEAD)
display_name=$git_hash # you can edit display name whatever you want. defaults is hash value of git
## =====get some parameters from config file======
# I don't know why but somehow maxTrialCount and parallelTrialCount in config don't recognized by gcloud
# so that these parameters are obtained from config_file
maxTrialCount=$(python << EOF
import yaml
with open('${config_file}') as f:
config = yaml.safe_load(f)
print(config['maxTrialCount'])
EOF
)
parallelTrialCount=$(python << EOF
import yaml
with open('${config_file}') as f:
config = yaml.safe_load(f)
print(config['parallelTrialCount'])
EOF
)
## =====build and push docker image======
# image_uri is obtained from config_file with the following code
pip install yaml
image_uri=$(python << EOF
import yaml
with open('${config_file}') as f:
config = yaml.safe_load(f)
print(config['trialJobSpec']['workerPoolSpecs']['containerSpec']['imageUri'])
EOF
)
echo "USE ${image_uri}"
docker build . -t $image_uri --platform=linux/x86_64
docker push $image_uri
# https://cloud.google.com/sdk/gcloud/reference/ai/hp-tuning-jobs/create?hl=ja
gcloud ai hp-tuning-jobs create \
--display-name=$display_name \
--region=$region \
--project=$gcp_project \
--config=$config_file \
--max-trial-count=$maxTrialCount \
--parallel-trial-count=$parallelTrialCount \
--enable-web-access