gcloud ai custom-jobs create Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud ai custom-jobs create - create a new custom job
- SYNOPSIS
gcloud ai custom-jobs create--display-name=DISPLAY_NAME(--config=CONFIG--worker-pool-spec=[WORKER_POOL_SPEC,…])[--args=[ARG,…]][--command=[COMMAND,…]][--enable-dashboard-access][--enable-web-access][--labels=[KEY=VALUE,…]][--network=NETWORK][--persistent-resource-id=PERSISTENT_RESOURCE_ID][--python-package-uris=[PYTHON_PACKAGE_URIS,…]][--region=REGION][--service-account=SERVICE_ACCOUNT][--kms-key=KMS_KEY:--kms-keyring=KMS_KEYRING--kms-location=KMS_LOCATION--kms-project=KMS_PROJECT][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
- This command will attempt to run the custom job immediately upon creation.
- EXAMPLES
- To create a job under project
inregionexample, run:us-central1gcloudaicustom-jobscreate--region=us-central1--project=example--worker-pool-spec=replica-count=1,machine-type='n1-highmem-2',container-image-uri='gcr.io/ucaip-test/ucaip-training-test'--display-name=test - REQUIRED FLAGS
--display-name=DISPLAY_NAME- Display name of the custom job to create.
- Worker pool specification.
At least one of these must be specified:
--config=CONFIG- Path to the job configuration file. This file should be a YAML documentcontaining a`CustomJobSpec`.If an option is specified both in the configuration file **and** viacommand-line arguments, the command-line arguments override the configurationfile. Note that keys with underscore are invalid.
Example(YAML):
workerPoolSpecs:machineSpec:machineType:n1-highmem-2replicaCount:1containerSpec:imageUri:gcr.io/ucaip-test/ucaip-training-testargs:-port=8500command:-start
--worker-pool-spec=[WORKER_POOL_SPEC,…]- Define the worker pool configuration used by the custom job. You can specifymultiple worker pool specs in order to create a custom job with multiple workerpools.
The spec can contain the following fields:
machine-type- (Required): The type of the machine. seehttps://cloud.google.com/vertex-ai/docs/training/configure-compute#machine-typesfor supported types. This is corresponding to the
machineSpec.machineTypefield inWorkerPoolSpecAPImessage. replica-count- The number of worker replicas to use for this worker pool, by default the valueis 1. This is corresponding to the
replicaCountfield inWorkerPoolSpecAPI message. accelerator-type- The type of GPUs. seehttps://cloud.google.com/vertex-ai/docs/training/configure-compute#specifying_gpusfor more requirements. This is corresponding to the
machineSpec.acceleratorTypefield inWorkerPoolSpecAPI message. accelerator-count- The number of GPUs for each VM in the worker pool to use, by default the valueif 1. This is corresponding to the
machineSpec.acceleratorCountfield inWorkerPoolSpecAPI message. container-image-uri- The URI of a container image to be directly run on each worker replica. This iscorresponding to the
containerSpec.imageUrifield inWorkerPoolSpecAPI message. executor-image-uri- The URI of a container image that will run the provided package.
output-image-uri- The URI of a custom container image to be built for autopackaged custom jobs.
python-module- The Python module name to run within the provided package.
local-package-path- The local path of a folder that contains training code.
script- The relative path under the
local-package-pathto a file toexecute. It can be a Python file or an arbitrary bash script. requirements- Python dependencies to be installed from PyPI, separated by ";". This issupposed to be used when some public packages are required by your trainingapplication but not in the base images. It has the same effect as editing a"requirements.txt" file under
local-package-path. extra-packages- Relative paths of local Python archives to be installed, separated by ";". Thisis supposed to be used when some custom packages are required by your trainingapplication but not in the base images. Every path should be relative to the
local-package-path. extra-dirs- Relative paths of the folders under
local-package-pathto be copiedinto the container, separated by ";". If not specified, only the parentdirectory that contains the main executable (scriptorpython-module) will be copied.
container-image-uri- Specify this field to use a custom container image for training. Together withthe
--commandand--argsflags, this field representsa`WorkerPoolSpec.ContainerSpec`message. In this case, the--python-package-urisflag isdisallowed.Example:--worker-pool-spec=replica-count=1,machine-type=n1-highmem-2,container-image-uri=gcr.io/ucaip-test/ucaip-training-test
executor-image-uri, python-module- Specify these fields to train using a pre-built container and Python packagesthat are already in Cloud Storage. Together with the
--python-package-urisand--argsflags, these fieldsrepresent a`WorkerPoolSpec.PythonPackageSpec`message .Example:--worker-pool-spec=machine-type=e2-standard-4,executor-image-uri=us-docker.pkg.dev/vertex-ai/training/tf-cpu.2-4:latest,python-module=trainer.task
output-image-uri- Specify this field to push the output custom container training image to aspecific path in Container Registry or Artifact Registry for an autopackagedcustom job.
Example:--worker-pool-spec=machine-type=e2-standard-4,executor-image-uri=us-docker.pkg.dev/vertex-ai/training/tf-cpu.2-4:latest,output-image-uri='eu.gcr.io/projectName/imageName',python-module=trainer.task
local-package-path, executor-image-uri, output-image-uri, python-module|script- Specify these fields, optionally with
requirements,extra-packages, orextra-dirs, to train using apre-built container and Python code from a local path. In this case, the--python-package-urisflag is disallowed.Example using
python-module:--worker-pool-spec=machine-type=e2-standard-4,replica-count=1,executor-image-uri=us-docker.pkg.dev/vertex-ai/training/tf-cpu.2-4:latest,python-module=trainer.task,local-package-path=/usr/page/applicationExample using
script:--worker-pool-spec=machine-type=e2-standard-4,replica-count=1,executor-image-uri=us-docker.pkg.dev/vertex-ai/training/tf-cpu.2-4:latest,script=my_run.sh,local-package-path=/usr/jeff/application
- OPTIONAL FLAGS
--args=[ARG,…]- Comma-separated arguments passed to containers or python tasks.
--command=[COMMAND,…]- Command to be invoked when containers are started. It overrides the entrypointinstruction in Dockerfile when provided.
--enable-dashboard-access- Whether you want Vertex AI to enable dashboard built on the training containers.If set to
, you can access thedashboard at the URIs given by CustomJob.web_access_uris orTrial.web_access_uris (within HyperparameterTuningJob.trials).true --enable-web-access- Whether you want Vertex AI to enableinteractiveshell access to training containers. If set to
, you can access interactive shells atthe URIs given by CustomJob.web_access_uris or Trial.web_access_uris (withinHyperparameterTuningJob.trials).true --labels=[KEY=VALUE,…]- List of label KEY=VALUE pairs to add.
Keys must start with a lowercase character and contain only hyphens(
-), underscores (_), lowercase characters, andnumbers. Values must contain only hyphens (-), underscores(_), lowercase characters, and numbers. --network=NETWORK- Full name of the Google Compute Engine network to which the Job is peered with.Private services access must already have been configured. If unspecified, theJob is not peered with any network.
--persistent-resource-id=PERSISTENT_RESOURCE_ID- The name of the persistent resource from the same project and region on which torun this custom job.
If this is specified, the job will be run on existing machines held by thePersistentResource instead of on-demand short-lived machines. The network andCMEK configs on the job should be consistent with those on thePersistentResource, otherwise, the job will be rejected.
--python-package-uris=[PYTHON_PACKAGE_URIS,…]- The common Python package URIs to be used for training with a pre-builtcontainer image. e.g.
--python-package-uri=path1,path2If you areusing multiple worker pools and want to specify a different Python packag foreach pool, use--configinstead. - Region resource - Cloud region to create a custom job. This represents a Cloudresource. (NOTE) Some attributes are not given arguments in this group but canbe set in other ways.
To set the
projectattribute:- provide the argument
--regionon the command line with a fullyspecified name; - set the property
ai/regionwith a fully specified name; - choose one from the prompted list of available regions with a fully specifiedname;
- provide the argument
--projecton the command line; - set the property
core/project.
- provide the argument
--region=REGION- ID of the region or fully qualified identifier for the region.
To set the
regionattribute:- provide the argument
--regionon the command line; - set the property
ai/region; - choose one from the prompted list of available regions.
- provide the argument
--service-account=SERVICE_ACCOUNT- The email address of a service account to use when running the trainingappplication. You must have the
iam.serviceAccounts.actAspermission for the specified service account. - Key resource - The Cloud KMS (Key Management Service) cryptokey that will beused to protect the custom job. The 'Vertex AI Service Agent' service accountmust hold permission 'Cloud KMS CryptoKey Encrypter/Decrypter'. The arguments inthis group can be used to specify the attributes of this resource.
--kms-key=KMS_KEY- ID of the key or fully qualified identifier for the key.
To set the
kms-keyattribute:- provide the argument
--kms-keyon the command line.
This flag argument must be specified if any of the other arguments in this groupare specified.
- provide the argument
--kms-keyring=KMS_KEYRING- The KMS keyring of the key.
To set the
kms-keyringattribute:- provide the argument
--kms-keyon the command line with a fullyspecified name; - provide the argument
--kms-keyringon the command line.
- provide the argument
--kms-location=KMS_LOCATION- The Google Cloud location for the key.
To set the
kms-locationattribute:- provide the argument
--kms-keyon the command line with a fullyspecified name; - provide the argument
--kms-locationon the command line.
- provide the argument
--kms-project=KMS_PROJECT- The Google Cloud project for the key.
To set the
kms-projectattribute:- provide the argument
--kms-keyon the command line with a fullyspecified name; - provide the argument
--kms-projecton the command line; - set the property
core/project.
- provide the argument
- GCLOUD WIDE FLAGS
- These flags are available to all commands:
--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.Run
$gcloud helpfor details. - NOTES
- These variants are also available:
gcloudalphaaicustom-jobscreategcloudbetaaicustom-jobscreate
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-01-21 UTC.