CustomJob class in the google-cloud-aiplatform SDK. The parameters of a CustomJob can be controlled with the launch queue configuration. Vertex AI cannot be configured to pull images from a private registry outside of Google Cloud. This means that you must store container images in Google Cloud or in a public registry if you want to use Vertex AI with W&B Launch. See the Vertex AI documentation for more information on making container images accessible to Vertex jobs.
Prerequisites
- Create or access a Google Cloud project with the Vertex AI API enabled. See the Google Cloud API Console docs for more information on enabling an API.
- Create a Google Cloud Artifact Registry repository to store images you want to execute on Vertex. See the Google Cloud Artifact Registry documentation for more information.
- Create a staging GCS bucket for Vertex AI to store its metadata. Note that this bucket must be in the same region as your Vertex AI workloads in order to be used as a staging bucket. The same bucket can be used for staging and build contexts.
- Create a service account with the necessary permissions to spin up Vertex AI jobs. See the Google Cloud IAM documentation for more information on assigning permissions to service accounts.
- Grant your service account permission to manage Vertex jobs
| Permission | Resource Scope | Description |
|---|---|---|
aiplatform.customJobs.create | Specified Google Cloud Project | Allows creation of new machine learning jobs within the project. |
aiplatform.customJobs.list | Specified Google Cloud Project | Allows listing of machine learning jobs within the project. |
aiplatform.customJobs.get | Specified Google Cloud Project | Allows retrieval of information about specific machine learning jobs within the project. |
If you want your Vertex AI workloads to assume the identity of a non-standard service account, refer to the Vertex AI documentation for instructions on service account creation and necessary permissions. The
spec.service_account field of the launch queue configuration can be used to select a custom service account for your W&B runs.Configure a queue for Vertex AI
The queue configuration for Vertex AI resources specify inputs to theCustomJob constructor in the Vertex AI Python SDK, and the run method of the CustomJob. Resource configurations are stored under the spec and run keys:
- The
speckey contains values for the named arguments of theCustomJobconstructor in the Vertex AI Python SDK. - The
runkey contains values for the named arguments of therunmethod of theCustomJobclass in the Vertex AI Python SDK.
spec.worker_pool_specs list. A worker pool spec defines a group of workers that will run your job. The worker spec in the default config asks for a single n1-standard-4 machine with no accelerators. You can change the machine type, accelerator type and count to suit your needs.
For more information on available machine types and accelerator types, see the Vertex AI documentation.
Create a queue
Create a queue in the W&B App that uses Vertex AI as its compute resource:- Navigate to the Launch page.
- Click on the Create Queue button.
- Select the Entity you would like to create the queue in.
- Provide a name for your queue in the Name field.
- Select Google Cloud Vertex AI as the Resource.
- Within the Configuration field, provide information about your Vertex AI
CustomJobyou defined in the previous section. By default, W&B will populate a YAML and JSON request body similar to the following:
- After you configure your queue, click on the Create Queue button.
spec.worker_pool_specs: non-empty list of worker pool specifications.spec.staging_bucket: GCS bucket to be used for staging Vertex AI assets and metadata.
Some of the Vertex AI docs show worker pool specifications with all keys in camel case,for example,
workerPoolSpecs. The Vertex AI Python SDK uses snake case for these keys, for example worker_pool_specs.Every key in the launch queue configuration should use snake case.Configure a launch agent
The launch agent is configurable through a config file that is, by default, located at~/.config/wandb/launch-config.yaml.