This is a template repository for running Optuna optimization on Google Cloud Batch and GCS.
python>=3.11
docker
make
yq
gcloud
- Create two service accounts, SA1 and SA2. SA1 is for optimizer and SA2 is for job batches. Add permissions
roles/storage.objectUser
,roles/batch.jobsEditor
,roles/artifactregistry.reader
androles/logging.logWriter
to a service account for SA1 androles/storage.admin
,roles/artifactregistry.reader
,roles/batch.agentReporter
androles/logging.logWriter
for SA2. - Edit
optunabatch/custom.py
to define your objective function and study settings. - Edit
config.yaml
to define your cloud batch settings. Service account for the job instances (SA2) should be specified inservice_account
field. make build
to build the Docker images.make push
to push the Docker images to the Artifact Resigtry.- Create a GCE instance. You can use
make create-instance SERVICE_ACCOUNT={SA1}
to create a VM. The service account should have permissions forStorage Object User
,Batch Job Editor
andLogs Writer
. make update-container
to deploy the Docker images to the GCP.- Trials will be stored in the GCS bucket specified in
config.yaml
.
The command make run-optimizer
is for debugging in the local environment. Note that it uses credentials stored in ~/.config/gcloud/
.