forked from google-research/kubric
-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch.sh
executable file
·88 lines (76 loc) · 2.32 KB
/
launch.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
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash -x
# WARNING: verify credentials are enabled "gcloud auth configure-docker"
# WARNING: verify credentials are enabled "gcloud auth application-default login"
#JOB_NAME="kubric_$(date +"%b%d_%H%M%S" | tr A-Z a-z)"
PROJECT_ID="kubric-xgcp"
REGION="us-central1" #< WARNING: match region of bucket!
run_mode=${1}
shift # shifts all arguments to the left thus removing ${1}
worker_file=${1}
shift # shifts all arguments to the left thus removing ${1}
JOB_NAME=${1}
shift
NR_VIDEOS=${1}
shift
NR_WORKERS=${1}
shift
# --- Specify the hypertune configuration
cat > /tmp/hypertune.yml << EOF
trainingInput:
hyperparameters:
goal: MAXIMIZE
hyperparameterMetricTag: "answer"
maxTrials: $NR_VIDEOS
maxParallelTrials: $NR_WORKERS
maxFailedTrials: 100
enableTrialEarlyStopping: False
# --- each of these become an argparse argument
params:
- parameterName: seed
type: INTEGER
minValue: 0
maxValue: 52423
EOF
# --- The container configuration
cat > Dockerfile <<EOF
FROM kubricdockerhub/kubruntudev:latest
COPY . /workspace
WORKDIR /workspace
ENTRYPOINT ["python3", "/workspace/${worker_file}"]
EOF
if [[ "${run_mode}" == "local" ]] || [[ "${run_mode}" == "dev" ]]
then
# --- Launches the job locally
TAG="local"
docker build -f Dockerfile -t $TAG $PWD
docker run $TAG "$@"
elif [[ "${run_mode}" == "remote" ]]
then
# --- Parameters for the launch
TAG="gcr.io/$PROJECT_ID/worker"
docker build -f Dockerfile -t $TAG $PWD
docker push $TAG
# --- Launches the job on aiplatform
gcloud beta ai-platform jobs submit training $JOB_NAME \
--region $REGION \
--scale-tier basic \
--master-image-uri $TAG \
--job-dir "gs://research-brain-kubric-xgcp/jobs/$JOB_NAME" \
-- "$@"
# --- Streams the job logs to local terminal
gcloud ai-platform jobs stream-logs $JOB_NAME
else # hyper
# --- Parameters for the launch
TAG="gcr.io/$PROJECT_ID/$JOB_NAME"
docker build -f Dockerfile -t $TAG $PWD
docker push $TAG
# --- Launches the job on aiplatform
gcloud beta ai-platform jobs submit training $JOB_NAME \
--region $REGION \
--scale-tier basic \
--master-image-uri $TAG \
--config /tmp/hypertune.yml \
--job-dir "gs://research-brain-kubric-xgcp/jobs/$JOB_NAME" \
-- "$@"
gcloud ai-platform jobs describe $JOB_NAME
fi