This example shows how to take an embarrasingly parallel job and run it on Cloud Batch job using C++.
If you are not familiar with the Batch API, we recommend you first read the API overview before starting this guide.
The following steps are included:
- Create a docker image
- Upload it to Artifact registry
- Create the Cloud Batch job
- Install the gcloud CLI.
- Install docker.
The instructions are here.
- [If it does not already exist] Create the artifact repository
- Build the image locally
- Tag and push the image to the artifact repository
To run this example, replace the [PROJECT ID] placeholder with the id of your
project:
Authorize via gcloud cli
PROJECT_ID=[PROJECT_ID]
LOCATION="us-central1"
REPOSITORY="parallel-repo"
gcloud auth login
gcloud config set project ${PROJECT_ID}
# Create the repository
gcloud artifacts repositories create ${REPOSITORY} \
--repository-format=docker \
--location=${LOCATION} \
--description="Store the example parallel C++ application" \
--asyncTo verify repo was created
``` gcloud artifacts repositories list ```You should see something like
parallel-repo DOCKER STANDARD_REPOSITORY Store the example parallel C++ application us-central1 Google-managed key 2024-05-21T12:39:54 2024-05-21T12:39:54 0
cd batch/parallel/application
docker build --tag=fimsim-image:latest .
cd batch/parallel/application
gcloud builds submit --region=${LOCATION} --tag ${LOCATION}-docker.pkg.dev/${PROJECT_ID}/${REPOSITORY}/finsim-image:latest
- Replace the
imageURIfield in application.json
"runnables": [
{
"container": {
"imageUri": "${LOCATION_ID}-docker.pkg.dev/${PROJECT_ID}/{REPOSITORY}/finsim-image:latest",
}
}
],
- Submit the job
gcloud batch jobs submit cpp-finsim-cli-run \
--config=finsim.json \
--location=us-central1
- Check on the job status
gcloud batch jobs describe cpp-finsim-cli-run --location=us-central1