- 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
in regionexample
, run:us-central1
gcloud ai custom-jobs create --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 document
containing a `CustomJobSpec`.
If an option is specified both in the configuration file **and** via
command-line arguments, the command-line arguments override the configuration
file. Note that keys with underscore are invalid.
Example(YAML):
workerPoolSpecs: machineSpec: machineType: n1-highmem-2 replicaCount: 1 containerSpec: imageUri: gcr.io/ucaip-test/ucaip-training-test args: - port=8500 command: - start
--worker-pool-spec
=[WORKER_POOL_SPEC
,…]-
Define the worker pool configuration used by the custom job. You can specify
multiple worker pool specs in order to create a custom job with multiple worker
pools.
The spec can contain the following fields:
machine-type
-
(Required): The type of the machine. see https://cloud.google.com/vertex-ai/docs/training/configure-compute#machine-types
for supported types. This is corresponding to the
machineSpec.machineType
field inWorkerPoolSpec
API message. replica-count
-
The number of worker replicas to use for this worker pool, by default the value
is 1. This is corresponding to the
replicaCount
field inWorkerPoolSpec
API message. accelerator-type
-
The type of GPUs. see https://cloud.google.com/vertex-ai/docs/training/configure-compute#specifying_gpus
for more requirements. This is corresponding to the
machineSpec.acceleratorType
field inWorkerPoolSpec
API message. accelerator-count
-
The number of GPUs for each VM in the worker pool to use, by default the value
if 1. This is corresponding to the
machineSpec.acceleratorCount
field inWorkerPoolSpec
API message. container-image-uri
-
The URI of a container image to be directly run on each worker replica. This is
corresponding to the
containerSpec.imageUri
field inWorkerPoolSpec
API 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-path
to a file to execute. It can be a Python file or an arbitrary bash script. requirements
-
Python dependencies to be installed from PyPI, separated by ";". This is
supposed to be used when some public packages are required by your training
application 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 ";". This
is supposed to be used when some custom packages are required by your training
application 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-path
to be copied into the container, separated by ";". If not specified, only the parent directory that contains the main executable (script
orpython-module
) will be copied.
container-image-uri
-
Specify this field to use a custom container image for training. Together with
the
--command
and--args
flags, this field represents a `WorkerPoolSpec.ContainerSpec` message. In this case, the--python-package-uris
flag is disallowed.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 packages
that are already in Cloud Storage. Together with the
--python-package-uris
and--args
flags, these fields represent 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 a
specific path in Container Registry or Artifact Registry for an autopackaged
custom 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 a pre-built container and Python code from a local path. In this case, the--python-package-uris
flag 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 entrypoint instruction 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 the dashboard at the URIs given by CustomJob.web_access_uris or Trial.web_access_uris (within HyperparameterTuningJob.trials).true
--enable-web-access
-
Whether you want Vertex AI to enable interactive
shell access to training containers. If set to
, you can access interactive shells at the URIs given by CustomJob.web_access_uris or Trial.web_access_uris (within HyperparameterTuningJob.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, and numbers. 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, the Job 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 to
run this custom job.
If this is specified, the job will be run on existing machines held by the PersistentResource instead of on-demand short-lived machines. The network and CMEK configs on the job should be consistent with those on the PersistentResource, 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-built
container image. e.g.
--python-package-uri=path1,path2
If you are using multiple worker pools and want to specify a different Python packag fo reach pool, use--config
instead. -
Region resource - Cloud region to create a custom job. This represents a Cloud
resource. (NOTE) Some attributes are not given arguments in this group but can
be set in other ways.
To set the
project
attribute:-
provide the argument
--region
on the command line with a fully specified name; -
set the property
ai/region
with a fully specified name; - choose one from the prompted list of available regions with a fully specified name;
-
provide the argument
--project
on the command line; -
set the property
core/project
.
--region
=REGION
-
ID of the region or fully qualified identifier for the region.
To set the
region
attribute:-
provide the argument
--region
on the command line; -
set the property
ai/region
; - choose one from the prompted list of available regions.
-
provide the argument
-
provide the argument
--service-account
=SERVICE_ACCOUNT
-
The email address of a service account to use when running the training
appplication. You must have the
iam.serviceAccounts.actAs
permission for the specified service account. -
Key resource - The Cloud KMS (Key Management Service) cryptokey that will be
used to protect the custom job. The 'Vertex AI Service Agent' service account
must hold permission 'Cloud KMS CryptoKey Encrypter/Decrypter'. The arguments in
this 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-key
attribute:-
provide the argument
--kms-key
on the command line.
This flag argument must be specified if any of the other arguments in this group are specified.
-
provide the argument
--kms-keyring
=KMS_KEYRING
-
The KMS keyring of the key.
To set the
kms-keyring
attribute:-
provide the argument
--kms-key
on the command line with a fully specified name; -
provide the argument
--kms-keyring
on the command line.
-
provide the argument
--kms-location
=KMS_LOCATION
-
The Google Cloud location for the key.
To set the
kms-location
attribute:-
provide the argument
--kms-key
on the command line with a fully specified name; -
provide the argument
--kms-location
on the command line.
-
provide the argument
--kms-project
=KMS_PROJECT
-
The Google Cloud project for the key.
To set the
kms-project
attribute:-
provide the argument
--kms-key
on the command line with a fully specified name; -
provide the argument
--kms-project
on 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 help
for details. - NOTES
-
These variants are also available:
gcloud alpha ai custom-jobs create
gcloud beta ai custom-jobs create
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-04-16 UTC.