Stay organized with collections Save and categorize content based on your preferences.
CustomJob(
display_name: str,
worker_pool_specs: Union[
List[Dict], List[google.cloud.aiplatform_v1.types.custom_job.WorkerPoolSpec]
],
base_output_dir: Optional[str] = None,
project: Optional[str] = None,
location: Optional[str] = None,
credentials: Optional[google.auth.credentials.Credentials] = None,
labels: Optional[Dict[str, str]] = None,
encryption_spec_key_name: Optional[str] = None,
staging_bucket: Optional[str] = None,
)
Vertex AI Custom Job.
Inheritancebuiltins.object > google.cloud.aiplatform.base.VertexAiResourceNoun > builtins.object > google.cloud.aiplatform.base.FutureManager > google.cloud.aiplatform.base.VertexAiResourceNounWithFutureManager > google.cloud.aiplatform.jobs._Job > google.cloud.aiplatform.jobs._RunnableJob > CustomJob Properties networkThe full name of the Google Compute Engine network to which this CustomJob should be peered.
Takes the format projects/{project}/global/networks/{network}
. Where {project} is a project number, as in 12345
, and {network} is a network name.
Private services access must already be configured for the network. If left unspecified, the CustomJob is not peered with any network.
Methods CustomJobCustomJob(
display_name: str,
worker_pool_specs: Union[
List[Dict], List[google.cloud.aiplatform_v1.types.custom_job.WorkerPoolSpec]
],
base_output_dir: Optional[str] = None,
project: Optional[str] = None,
location: Optional[str] = None,
credentials: Optional[google.auth.credentials.Credentials] = None,
labels: Optional[Dict[str, str]] = None,
encryption_spec_key_name: Optional[str] = None,
staging_bucket: Optional[str] = None,
)
Cosntruct a Custom Job with Worker Pool Specs.
Example usage:
worker_pool_specs = [
{
"machine_spec": {
"machine_type": "n1-standard-4",
"accelerator_type": "NVIDIA_TESLA_K80",
"accelerator_count": 1,
},
"replica_count": 1,
"container_spec": {
"image_uri": container_image_uri,
"command": [],
"args": [],
},
}
]
my_job = aiplatform.CustomJob(
display_name='my_job',
worker_pool_specs=worker_pool_specs,
labels={'my_key': 'my_value'},
)
my_job.run()
For more information on configuring worker pool specs please visit: https://cloud.google.com/ai-platform-unified/docs/training/create-custom-job
Parameters Name Description display_namestr
Required. The user-defined name of the HyperparameterTuningJob. The name can be up to 128 characters long and can be consist of any UTF-8 characters.
worker_pool_specsUnion[List[Dict], List[aiplatform.gapic.WorkerPoolSpec]]
Required. The spec of the worker pools including machine type and Docker image. Can provided as a list of dictionaries or list of WorkerPoolSpec proto messages.
base_output_dirstr
Optional. GCS output directory of job. If not provided a timestamped directory in the staging directory will be used.
projectstr
Optional.Project to run the custom job in. Overrides project set in aiplatform.init.
locationstr
Optional.Location to run the custom job in. Overrides location set in aiplatform.init.
credentialsauth_credentials.Credentials
Optional.Custom credentials to use to run call custom job service. Overrides credentials set in aiplatform.init.
labelsDict[str, str]
Optional. The labels with user-defined metadata to organize CustomJobs. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.
encryption_spec_key_namestr
Optional.Customer-managed encryption key name for a CustomJob. If this is set, then all resources created by the CustomJob will be encrypted with the provided encryption key.
staging_bucketstr
Optional. Bucket for produced custom job artifacts. Overrides staging_bucket set in aiplatform.init.
Exceptions Type Description RuntimeError If staging bucket was not set using aiplatform.init and a staging bucke was not passed in.: from_local_scriptfrom_local_script(
display_name: str,
script_path: str,
container_uri: str,
args: Optional[Sequence[str]] = None,
requirements: Optional[Sequence[str]] = None,
environment_variables: Optional[Dict[str, str]] = None,
replica_count: int = 1,
machine_type: str = "n1-standard-4",
accelerator_type: str = "ACCELERATOR_TYPE_UNSPECIFIED",
accelerator_count: int = 0,
boot_disk_type: str = "pd-ssd",
boot_disk_size_gb: int = 100,
reduction_server_replica_count: int = 0,
reduction_server_machine_type: Optional[str] = None,
reduction_server_container_uri: Optional[str] = None,
base_output_dir: Optional[str] = None,
project: Optional[str] = None,
location: Optional[str] = None,
credentials: Optional[google.auth.credentials.Credentials] = None,
labels: Optional[Dict[str, str]] = None,
encryption_spec_key_name: Optional[str] = None,
staging_bucket: Optional[str] = None,
)
Configures a custom job from a local script.
Example usage:
job = aiplatform.CustomJob.from_local_script(
display_name="my-custom-job",
script_path="training_script.py",
container_uri="gcr.io/cloud-aiplatform/training/tf-cpu.2-2:latest",
requirements=["gcsfs==0.7.1"],
replica_count=1,
args=['--dataset', 'gs://my-bucket/my-dataset',
'--model_output_uri', 'gs://my-bucket/model']
labels={'my_key': 'my_value'},
)
job.run()
Parameters Name Description display_name str
Required. The user-defined name of this CustomJob.
script_pathstr
Required. Local path to training script.
container_uristr
Required: Uri of the training container image to use for custom job.
argsOptional[Sequence[str]]
Optional. Command line arguments to be passed to the Python task.
requirementsSequence[str]
Optional. List of python packages dependencies of script.
environment_variablesDict[str, str]
Optional. Environment variables to be passed to the container. Should be a dictionary where keys are environment variable names and values are environment variable values for those names. At most 10 environment variables can be specified. The Name of the environment variable must be unique. environment_variables = { 'MY_KEY': 'MY_VALUE' }
replica_countint
Optional. The number of worker replicas. If replica count = 1 then one chief replica will be provisioned. If replica_count > 1 the remainder will be provisioned as a worker replica pool.
machine_typestr
Optional. The type of machine to use for training.
accelerator_typestr
Optional. Hardware accelerator type. One of ACCELERATOR_TYPE_UNSPECIFIED, NVIDIA_TESLA_K80, NVIDIA_TESLA_P100, NVIDIA_TESLA_V100, NVIDIA_TESLA_P4, NVIDIA_TESLA_T4
accelerator_countint
Optional. The number of accelerators to attach to a worker replica.
boot_disk_typestr
Optional. Type of the boot disk, default is pd-ssd
. Valid values: pd-ssd
(Persistent Disk Solid State Drive) or pd-standard
(Persistent Disk Hard Disk Drive).
int
Optional. Size in GB of the boot disk, default is 100GB. boot disk size must be within the range of [100, 64000].
reduction_server_replica_countint
The number of reduction server replicas, default is 0.
reduction_server_machine_typestr
Optional. The type of machine to use for reduction server.
reduction_server_container_uristr
Optional. The Uri of the reduction server container image. See details: https://cloud.google.com/vertex-ai/docs/training/distributed-training#reduce_training_time_with_reduction_server
base_output_dirstr
Optional. GCS output directory of job. If not provided a timestamped directory in the staging directory will be used.
projectstr
Optional. Project to run the custom job in. Overrides project set in aiplatform.init.
locationstr
Optional. Location to run the custom job in. Overrides location set in aiplatform.init.
credentialsauth_credentials.Credentials
Optional. Custom credentials to use to run call custom job service. Overrides credentials set in aiplatform.init.
labelsDict[str, str]
Optional. The labels with user-defined metadata to organize CustomJobs. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.
encryption_spec_key_namestr
Optional. Customer-managed encryption key name for a CustomJob. If this is set, then all resources created by the CustomJob will be encrypted with the provided encryption key.
staging_bucketstr
Optional. Bucket for produced custom job artifacts. Overrides staging_bucket set in aiplatform.init.
Exceptions Type Description RuntimeError If staging bucket was not set using aiplatform.init and a staging bucke was not passed in.: runrun(
service_account: Optional[str] = None,
network: Optional[str] = None,
timeout: Optional[int] = None,
restart_job_on_worker_restart: bool = False,
enable_web_access: bool = False,
tensorboard: Optional[str] = None,
sync: bool = True,
)
Run this configured CustomJob.
Parameters Name Description service_accountstr
Optional. Specifies the service account for workload run-as account. Users submitting jobs must have act-as permission on this run-as account.
networkstr
Optional. The full name of the Compute Engine network to which the job should be peered. For example, projects/12345/global/networks/myVPC. Private services access must already be configured for the network. If left unspecified, the job is not peered with any network.
timeoutint
The maximum job running time in seconds. The default is 7 days.
restart_job_on_worker_restartbool
Restarts the entire CustomJob if a worker gets restarted. This feature can be used by distributed training jobs that are not resilient to workers leaving and joining a job.
enable_web_accessbool
Whether you want Vertex AI to enable interactive shell access to training containers. https://cloud.google.com/vertex-ai/docs/training/monitor-debug-interactive-shell
tensorboardstr
Optional. The name of a Vertex AI Tensorboard resource to which this CustomJob will upload Tensorboard logs. Format: projects/{project}/locations/{location}/tensorboards/{tensorboard}
The training script should write Tensorboard to following Vertex AI environment variable: AIP_TENSORBOARD_LOG_DIR service_account
is required with provided tensorboard
. For more information on configuring your service account please visit: https://cloud.google.com/vertex-ai/docs/experiments/tensorboard-training
bool
Whether to execute this method synchronously. If False, this method will unblock and it will be executed in a concurrent Future.
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 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4