This document explains how to create and run a job that uses a graphics processing unit (GPU). To learn more about the features and restrictions for GPUs, see About GPUs in the Compute Engine documentation.
When you create a Batch job, you can optionally use GPUs to accelerate specific workloads. Common use cases for jobs that use GPUs include intensive data processing and artificial intelligence workloads (AI) such as machine learning (ML).
Before you begin
- If you haven't used Batch before, review Get started with Batch and enable Batch by completing the prerequisites for projects and users.
- 
  
  
  
  
  
  
  
    
    
    
    
    
    
      
      
        
        
        
        
        
      
    
      
      
        
        
        
        
        
      
    
    
    
    
    
  
  To get the permissions that you need to create a job, ask your administrator to grant you the following IAM roles: - 
  
  
    
      Batch Job Editor  (roles/batch.jobsEditor) on the project
- 
  
  
    
      Service Account User  (roles/iam.serviceAccountUser) on the job's service account, which by default is the default Compute Engine service account
 For more information about granting roles, see Manage access to projects, folders, and organizations. You might also be able to get the required permissions through custom roles or other predefined roles. 
- 
  
  
    
      Batch Job Editor  (
Create a job that uses GPUs
To create a job that uses GPUs, do the following:
- Plan the requirements for a job that uses GPUs.
- Create a job with the requirements and methods that you identified. For examples of how to create a job using the recommended options, see Create an example job that uses GPUs in this document.
Plan the requirements for a job that uses GPUs
Before creating a job that uses GPUs, plan the job's requirements as explained in the following sections:
- Select the GPU machine type and consumption option
- Install the GPU drivers
- Define compatible VM resources
Step 1: Select the GPU machine type and consumption option
A job's requirements vary based on your preferred GPU machine type and consumption option, and the options for each might be interdependent.
To select the GPU machine type and consumption option for your job, complete the following steps:
- Identify and select your priority: - If you want to prioritize performance and base pricing, then see the Select the GPU machine type section in this document.
- If you want to prioritize resource availability or discounts, then see the Select the consumption option section in this document.
 
- Make the remaining selection based on what is compatible with your first selection. - To identify the options that are compatible with your first selection, see Consumption option availability by machine type in the Compute Engine documentation. 
- See the remaining section for Select the consumption option or Select the GPU machine type respectively. 
 
Select the GPU machine type
To select the GPU machine type for a job and understand its job requirements, complete the following steps:
- Select a GPU machine type: To review the available GPU machine types (the valid combinations of GPU type, number of GPUs, and machine type (vCPUs and memory)) and their recommended use cases, see GPU machine types and Accelerator-optimized machine family in the Compute Engine documentation. 
- Understand the job requirements for your GPU machine type: The fields required for a job to specify a GPU machine type vary based on the categories in the following table: - GPU machine types and their job requirements - GPUs for accelerator-optimized VMs: VMs with a machine type from the accelerator-optimized machine family have a specific type and number of these GPUs automatically attached. - To use GPUs for accelerator-optimized VMs, we recommend that you specify the machine type. Each accelerator-optimized machine type supports only a specific type and number of GPUs, so it's functionally equivalent whether you do or don't specify those values in addition to the accelerator-optimized machine type. - Specifically, Batch also supports specifying only the type and number of GPUs for accelerator-optimized VMs, but the resulting vCPU and memory options are often very limited. As a result, we recommend that you verify that the available vCPU and memory options are compatible with the job's task requirements. - GPUs for N1 VMs: These GPUs require you to specify the type and amount to attach to each VM and must be attached to VMs with a machine type from the N1 machine series. - To use GPUs for N1 VMs, we recommend that you specify at least the type of GPUs and number of GPUs. Make sure that the combination of values matches one of the valid GPU options for the N1 machine types. The vCPU and memory options for N1 VMs that use any specific type and number GPUs is quite flexible. Unless you create the job using the Google Cloud console, you can let Batch automatically select a machine type that meets the job's task requirements. 
Select the consumption option
This section summarizes how to select the consumption option for a job and the job requirements for each option.
The available consumption options for Batch and their requirements are explained in the following table, which lists them based on their use cases: from roughly highest to lowest resource availability.
In summary, we recommend that most users select the consumption option for a job as follows:
- Unless one of the other conditions is true, use Flex-start VMs (Preview) (preferred, if it meets your requirements) or on-demand.
- If your job requires very high assurance of resource availability or if you have any unused reservations that you can't delete, then use calendar-mode reservations (Preview) (preferred, if it meets your requirements) or reservations.
- (Optional) If your workload is very fault-tolerant, then you might be able to reduce costs by trying to use Spot VMs.
| Consumption options and their job requirements | |
|---|---|
| Reservations 
 | Batch uses reservations for jobs that can consume unused reserved VMs. For more information about the job requirements for consuming reservations, see the Ensure resource availability using VM reservations page. | 
| Calendar-mode reservations (Preview) 
 | Batch uses calendar-mode reservations for jobs that do all of the following: 
 | 
| Flex-start VMs (Preview) 
 | Batch uses Flex-start VMs for jobs that do all of the following: 
 | 
| On-demand 
 | Batch uses on-demand for most other jobs by default. If a job you want to ensure that a job uses on-demand, do all of the following:1 
 1Exception: For jobs that use the A3 machine series, the default
    behavior is unique, and we recommend that you don't use on-demand and don't
    leave the  | 
| Spot VMs 
 | Batch uses Spot VMs for jobs that do all of the following: 
 | 
Step 2: Install the GPU drivers
To use GPUs for a job, you must install the GPU drivers. To install GPU drivers, select one of the following methods:
- Install GPU drivers automatically (recommended if possible): As shown in the examples, to let Batch fetch the required GPU drivers from a third-party location and install them on your behalf, set the - installGpuDriversfield for the job to- true. This method is recommended if your job does not require you to install drivers manually.- Optionally, if you need to specify which version of the GPU driver that Batch installs, also set the - driverVersionfield.
- Install GPU drivers manually: This method is required if any of the following are true: - A job uses both script and container runnables and does not have internet access. For more information about the access a job has, see Batch networking overview.
- A job uses a custom VM image. To learn more about VM OS images and which VM OS images you can use, see VM OS environment overview.
 - To manually install the required GPU drivers, the following method is recommended: - Create a custom VM image that includes the GPU drivers. - To install GPU drivers, run an installation script based on the OS that you want to use: 
- If your job has any container runnables and does not use Container-Optimized OS, you must also install the NVIDIA Container Toolkit 
 
- When you create and submit a job that uses GPUs, specify the custom VM image that includes the GPU drivers, and set the - installGpuDriversfield for the job to- false(default).
 
Step 3: Define compatible VM resources
To learn about the requirements and options for defining the VM resources for a job, see Job resources.
In summary, you must do all of the following when defining the VM resources for a job that uses GPUs:
- Make sure that the GPU machine type is available in the location of your job's VMs. - To learn where GPU machine types are available, see GPU availability by regions and zones in the Compute Engine documentation. 
- If you specify the job's machine type, make sure that machine type has enough vCPUs and memory for the job's task requirements. Specifying the job's machine type is required whenever you create a job using the Google Cloud console and is recommended whenever you are creating a job that uses GPUs for accelerator-optimized VMs. 
- Make sure you define the VM resources for a job using a valid method: - Define VM resources directly by using the instances[].policyfield (recommended if possible). This method is shown in the examples.
- Define VM resources through a template by using the instances[].instanceTemplatefield. This method is required to manually install GPU drivers through a custom image. For more information, see Define job resources using a VM instance template.
 
- Define VM resources directly by using the 
Create an example job that uses GPUs
The following sections explain how to create an example job for each consumption option. Specifically, the example jobs use the recommended options: all install GPU drivers automatically, and all directly define VM resources.
| Consumption option | Example job instructions | 
|---|---|
| Reservations or calendar-mode reservations (Preview) | |
| Flex-start VMs (Preview) | |
| On-demand or Spot VMs | Select one of the following options based on your GPU machine type: | 
Use GPUs and Flex-start VMs
You can create a job that uses GPUs for A3 VMs through Dynamic Workload Scheduler using gcloud CLI or Batch API.
gcloud
- Create a JSON file that installs GPU drivers, specifies a GPU machine type that supports Flex-start VMs, blocks reservations, and runs in a location that supports the GPU machine type. - For example, to create a basic script job that uses Flex-start VMs and GPUs for accelerator-optimized VMs, create a JSON file with the following contents. - { "taskGroups": [ { "taskSpec": { "runnables": [ { "script": { "text": "echo Hello world from task ${BATCH_TASK_INDEX}." } } ] }, "taskCount": 3, "parallelism": 1 } ], "allocationPolicy": { "instances": [ { "installGpuDrivers": INSTALL_GPU_DRIVERS, "policy": { "provisioningModel":"FLEX_START", "machineType": "MACHINE_TYPE", "reservation": "NO_RESERVATION" } } ], "location": { "allowedLocations": [ "ALLOWED_LOCATIONS" ] } }, "logsPolicy": { "destination": "CLOUD_LOGGING" } }- Replace the following: - INSTALL_GPU_DRIVERS: When set to- true, Batch fetches the drivers required for the GPU type that you specify in the- policyfield from a third-party location, and Batch installs them on your behalf. If you set this field to- false(default), you need to install GPU drivers manually to use any GPUs for this job.
- MACHINE_TYPE: a GPU machine type that supports Flex-start VMs. For more information, see Consumption option availability by machine type in the Compute Engine documentation.
- ALLOWED_LOCATIONS: You can optionally use the- allowedLocations[]field to specify a region or specific zone(s) in a region where the VMs for your job are allowed to run—for example,- regions/us-central1allows all zones in the region- us-central1. Make sure that you specify locations that offer the GPU machine type that you want for this job. Otherwise, if you omit this field, make sure the job's location offers the GPU machine type.
 
- To create and run the job, use the - gcloud alpha batch jobs submitcommand:- gcloud batch jobs submit JOB_NAME \ --location LOCATION \ --config JSON_CONFIGURATION_FILE- Replace the following: - JOB_NAME: the name of the job.
- LOCATION: the location of the job.
- JSON_CONFIGURATION_FILE: the path for a JSON file with the job's configuration details.
 
API
Make a POST request to the
v1alpha jobs.create method
that installs GPU drivers, specifies a GPU machine type that supports
Flex-start VMs, blocks reservations, and runs in a location that
supports the GPU machine type.
For example, to create a basic script job that uses Flex-start VMs and GPUs for accelerator-optimized VMs, make the following request:
POST https://batch.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION/jobs?job_id=JOB_NAME
{
    "taskGroups": [
        {
            "taskSpec": {
                "runnables": [
                    {
                        "script": {
                            "text": "echo Hello world from task ${BATCH_TASK_INDEX}."
                        }
                    }
                ]
            },
            "taskCount": 3,
            "parallelism": 1
        }
    ],
    "allocationPolicy": {
        "instances": [
            {
                "installGpuDrivers": INSTALL_GPU_DRIVERS,
                "policy": {
                    "provisioningModel":"FLEX_START",
                    "machineType": "MACHINE_TYPE",
                    "reservation": "NO_RESERVATION"
                }
            }
        ],
        "location": {
            "allowedLocations": [
                "ALLOWED_LOCATIONS"
            ]
        }
    },
    "logsPolicy": {
        "destination": "CLOUD_LOGGING"
    }
}
Replace the following:
- PROJECT_ID: the project ID of your project.
- LOCATION: the location of the job.
- JOB_NAME: the name of the job.
- INSTALL_GPU_DRIVERS: When set to- true, Batch fetches the drivers required for the GPU type that you specify in the- policyfield from a third-party location, and Batch installs them on your behalf. If you set this field to- false(default), you need to install GPU drivers manually to use any GPUs for this job.
- MACHINE_TYPE: a GPU machine type that supports Flex-start VMs. For more information, see Consumption option availability by machine type in the Compute Engine documentation.
- ALLOWED_LOCATIONS: You can optionally use the- allowedLocations[]field to specify a region or specific zone(s) in a region where the VMs for your job are allowed to run—for example,- regions/us-central1allows all zones in the region- us-central1. Make sure that you specify locations that offer the GPU machine type that you want for this job. Otherwise, if you omit this field, make sure the job's location offers the GPU machine type.
Use GPUs for accelerator-optimized VMs
You can create a job that uses GPUs for accelerator-optimized VMs using the Google Cloud console, gcloud CLI, Batch API, Java, Node.js, or Python.
Console
To create a job that uses GPUs by using the Google Cloud console, do the following:
- In the Google Cloud console, go to the Job list page. 
- Click Create. The Create batch job page opens. In the left pane, the Job details page is selected. 
- Configure the Job details page: - Optional: In the Job name field, customize the job name. - For example, enter - example-gpu-job.
- Configure the Task details section: - In the New runnable window, add at least one script or container for this job to run. - For example, to create a basic script job, do the following: - Select the Script checkbox. A field appears. 
- In the field, enter the following script: - echo Hello world from task ${BATCH_TASK_INDEX}.
- Click Done. 
 
- In the Task count field, enter the number of tasks for this job. - For example, enter - 3.
- Optional: In the Parallelism field, enter the number of tasks to run concurrently. - For example, enter - 1(default).
 
 
- Configure the Resource specifications page: - In the left pane, click Resource specifications. The Resource specifications page opens. 
- In the VM provisioning model section, select one of the following options for the consumption option for this job's VMs: - If your job can withstand preemption and you want discounted Spot VMs, select Spot. 
- Otherwise, to use on-demand VMs, select Standard (default). 
 
- Select the location for this job. - In the Region field, select a region. 
- In the Zone field, do one of the following: - If you want to restrict this job to run in a specific zone only, select a zone. 
- Otherwise, select any (default). 
 
 
- Select the GPU machine type for this job's VMs: - In the machine family options, click GPUs. 
- In the GPU type field, select the type of GPUs. Then, in the Number of GPUs field, select the number of GPUs for each VM. - If you selected one of the GPU types for accelerator-optimized VMs, then the Machine type field only allows one option for the machine type based on the type and number of GPUs that you selected. 
- To automatically install GPU drivers, select GPU driver installation (default). 
 
- Configure the amount of VM resources required for each task: - In the Cores field, enter the amount of vCPUs per task. - For example, enter - 1(default).
- In the Memory field, enter the amount of RAM in GB per task. - For example, enter - 0.5(default).
 
- Click Done. 
 
- Optional: Configure the other fields for this job. 
- Optional: To review the job configuration, in the left pane, click Preview. 
- Click Create. - The Job details page displays the job that you created. 
gcloud
- Create a JSON file that installs GPU drivers, specifies a machine type from the accelerator-optimized machine family, and runs in a location that has the GPU machine type. - For example, to create a basic script job that uses GPUs for accelerator-optimized VMs, create a JSON file with the following contents: - { "taskGroups": [ { "taskSpec": { "runnables": [ { "script": { "text": "echo Hello world from task ${BATCH_TASK_INDEX}." } } ] }, "taskCount": 3, "parallelism": 1 } ], "allocationPolicy": { "instances": [ { "installGpuDrivers": INSTALL_GPU_DRIVERS, "policy": { "provisioningModel": "PROVISIONING_MODEL", "machineType": "MACHINE_TYPE", "reservation": "NO_RESERVATION" } } ], "location": { "allowedLocations": [ "ALLOWED_LOCATIONS" ] } }, "logsPolicy": { "destination": "CLOUD_LOGGING" } }- Replace the following: - INSTALL_GPU_DRIVERS: When set to- true, Batch fetches the drivers required for the GPU type that you specify in the- policyfield from a third-party location, and Batch installs them on your behalf. If you set this field to- false(default), you need to install GPU drivers manually to use any GPUs for this job.
- PROVISIONING_MODEL: the provisioning model for your consumption option: either- STANDARDfor on-demand or- SPOTfor Spot VMs.
- MACHINE_TYPE: a machine type from the accelerator-optimized machine family.
- ALLOWED_LOCATIONS: You can optionally use the- allowedLocations[]field to specify a region or specific zone(s) in a region where the VMs for your job are allowed to run—for example,- regions/us-central1allows all zones in the region- us-central1. Make sure that you specify locations that offer the GPU machine type that you want for this job. Otherwise, if you omit this field, make sure the job's location offers the GPU machine type.
 
- To create and run the job, use the - gcloud batch jobs submitcommand:- gcloud batch jobs submit JOB_NAME \ --location LOCATION \ --config JSON_CONFIGURATION_FILE- Replace the following: - JOB_NAME: the name of the job.
- LOCATION: the location of the job.
- JSON_CONFIGURATION_FILE: the path for a JSON file with the job's configuration details.
 
API
Make a POST request to the
jobs.create method
that installs GPU drivers, specifies a machine type from the
accelerator-optimized machine family, and runs in a location that has the
GPU machine type.
For example, to create a basic script job that uses GPUs for accelerator-optimized VMs, make the following request:
POST https://batch.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/jobs?job_id=JOB_NAME
{
    "taskGroups": [
        {
            "taskSpec": {
                "runnables": [
                    {
                        "script": {
                            "text": "echo Hello world from task ${BATCH_TASK_INDEX}."
                        }
                    }
                ]
            },
            "taskCount": 3,
            "parallelism": 1
        }
    ],
    "allocationPolicy": {
        "instances": [
            {
                "installGpuDrivers": INSTALL_GPU_DRIVERS,
                "policy": {
                    "provisioningModel": "PROVISIONING_MODEL",
                    "machineType": "MACHINE_TYPE",
                    "reservation": "NO_RESERVATION"
                }
            }
        ],
        "location": {
            "allowedLocations": [
                "ALLOWED_LOCATIONS"
            ]
        }
    },
    "logsPolicy": {
        "destination": "CLOUD_LOGGING"
    }
}
Replace the following:
- PROJECT_ID: the project ID of your project.
- LOCATION: the location of the job.
- JOB_NAME: the name of the job.
- INSTALL_GPU_DRIVERS: When set to- true, Batch fetches the drivers required for the GPU type that you specify in the- policyfield from a third-party location, and Batch installs them on your behalf. If you set this field to- false(default), you need to install GPU drivers manually to use any GPUs for this job.
- PROVISIONING_MODEL: the provisioning model for your consumption option: either- STANDARDfor on-demand or- SPOTfor Spot VMs.
- MACHINE_TYPE: a machine type from the accelerator-optimized machine family.
- ALLOWED_LOCATIONS: You can optionally use the- allowedLocations[]field to specify a region or specific zone(s) in a region where the VMs for your job are allowed to run—for example,- regions/us-central1allows all zones in the region- us-central1. Make sure that you specify locations that offer the GPU machine type that you want for this job. Otherwise, if you omit this field, make sure the job's location offers the GPU machine type.
Java
Node.js
Python
Use GPUs for N1 VMs
You can create a job that uses GPUs for N1 VMs using the Google Cloud console, gcloud CLI, Batch API, Java, Node.js, or Python.
Console
To create a job that uses GPUs by using the Google Cloud console, do the following:
- In the Google Cloud console, go to the Job list page. 
- Click Create. The Create batch job page opens. In the left pane, the Job details page is selected. 
- Configure the Job details page: - Optional: In the Job name field, customize the job name. - For example, enter - example-gpu-job.
- Configure the Task details section: - In the New runnable window, add at least one script or container for this job to run. - For example, to create a basic script job, do the following: - Select the Script checkbox. A field appears. 
- In the field, enter the following script: - echo Hello world from task ${BATCH_TASK_INDEX}.
- Click Done. 
 
- In the Task count field, enter the number of tasks for this job. - For example, enter - 3.
- Optional: In the Parallelism field, enter the number of tasks to run concurrently. - For example, enter - 1(default).
 
 
- Configure the Resource specifications page: - In the left pane, click Resource specifications. The Resource specifications page opens. 
- In the VM provisioning model section, select one of the following options for the consumption option for this job's VMs: - If your job can withstand preemption and you want discounted Spot VMs, select Spot. 
- Otherwise, to use on-demand VMs, select Standard (default). 
 
- Select the location for this job. - In the Region field, select a region. 
- In the Zone field, do one of the following: - If you want to restrict this job to run in a specific zone only, select a zone. 
- Otherwise, select any (default). 
 
 
- Select the GPU machine type for this job's VMs: - In the machine family options, click GPUs. 
- In the GPU type field, select the type of GPUs. - If you selected one of the GPU types for N1 VMs, then the Series field is set to N1. 
- In the Number of GPUs field, select the number of GPUs for each VM. 
- In the Machine type field, select the machine type. 
- To automatically install GPU drivers, select GPU driver installation (default). 
 
- Configure the amount of VM resources required for each task: - In the Cores field, enter the amount of vCPUs per task. - For example, enter - 1(default).
- In the Memory field, enter the amount of RAM in GB per task. - For example, enter - 0.5(default).
 
- Click Done. 
 
- Optional: Configure the other fields for this job. 
- Optional: To review the job configuration, in the left pane, click Preview. 
- Click Create. - The Job details page displays the job that you created. 
gcloud
- Create a JSON file that installs GPU drivers, defines the - typeand- countsubfields of the- accelerators[]field, and runs in a location that has the GPU machine type.- For example, to create a basic script job that uses GPUs for N1 VMs and lets Batch select the exact N1 machine type, create a JSON file with the following contents: - { "taskGroups": [ { "taskSpec": { "runnables": [ { "script": { "text": "echo Hello world from task ${BATCH_TASK_INDEX}." } } ] }, "taskCount": 3, "parallelism": 1 } ], "allocationPolicy": { "instances": [ { "installGpuDrivers": INSTALL_GPU_DRIVERS, "policy": { "provisioningModel": "PROVISIONING_MODEL", "reservation": "NO_RESERVATION", "accelerators": [ { "type": "GPU_TYPE", "count": GPU_COUNT } ] } } ], "location": { "allowedLocations": [ "ALLOWED_LOCATIONS" ] } }, "logsPolicy": { "destination": "CLOUD_LOGGING" } }- Replace the following: - INSTALL_GPU_DRIVERS: When set to- true, Batch fetches the drivers required for the GPU type that you specify in the- policyfield from a third-party location, and Batch installs them on your behalf. If you set this field to- false(default), you need to install GPU drivers manually to use any GPUs for this job.
- PROVISIONING_MODEL: the provisioning model for your consumption option: either- STANDARDfor on-demand or- SPOTfor Spot VMs.
- GPU_TYPE: the GPU type. You can view a list of the available GPU types by using the- gcloud compute accelerator-types listcommand. Only use this field for GPUs for N1 VMs.
- GPU_COUNT: the number of GPUs of the specified type. For more information about the valid options, see the GPU machine types for the N1 machine series. Only use this field for GPUs for N1 VMs.
- ALLOWED_LOCATIONS: You can optionally use the- allowedLocations[]field to specify a region or specific zone(s) in a region where the VMs for your job are allowed to run—for example,- regions/us-central1allows all zones in the region- us-central1. Make sure that you specify locations that offer the GPU machine type that you want for this job. Otherwise, if you omit this field, make sure the job's location offers the GPU machine type.
 
- To create and run the job, use the - gcloud batch jobs submitcommand:- gcloud batch jobs submit JOB_NAME \ --location LOCATION \ --config JSON_CONFIGURATION_FILE- Replace the following: - JOB_NAME: the name of the job.
- LOCATION: the location of the job.
- JSON_CONFIGURATION_FILE: the path for a JSON file with the job's configuration details.
 
API
Make a POST request to the
jobs.create method
that installs GPU drivers, defines the
type and count subfields
of the accelerators[] field, and uses a location that has the GPU machine
type.
For example, to create a basic script job that uses GPUs for N1 VMs and lets Batch select the exact N1 machine type, make the following request:
POST https://batch.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/jobs?job_id=JOB_NAME
{
    "taskGroups": [
        {
            "taskSpec": {
                "runnables": [
                    {
                        "script": {
                            "text": "echo Hello world from task ${BATCH_TASK_INDEX}."
                        }
                    }
                ]
            },
            "taskCount": 3,
            "parallelism": 1
        }
    ],
    "allocationPolicy": {
        "instances": [
            {
                "installGpuDrivers": INSTALL_GPU_DRIVERS,
                "policy": {
                    "provisioningModel": "PROVISIONING_MODEL",
                    "reservation": "NO_RESERVATION",
                    "accelerators": [
                        {
                            "type": "GPU_TYPE",
                            "count": GPU_COUNT
                        }
                    ]
                }
            }
        ],
        "location": {
            "allowedLocations": [
                "ALLOWED_LOCATIONS"
            ]
        }
    },
    "logsPolicy": {
        "destination": "CLOUD_LOGGING"
    }
}
Replace the following:
- PROJECT_ID: the project ID of your project.
- LOCATION: the location of the job.
- JOB_NAME: the name of the job.
- INSTALL_GPU_DRIVERS: When set to- true, Batch fetches the drivers required for the GPU type that you specify in the- policyfield from a third-party location, and Batch installs them on your behalf. If you set this field to- false(default), you need to install GPU drivers manually to use any GPUs for this job.
- PROVISIONING_MODEL: the provisioning model for your consumption option: either- STANDARDfor on-demand or- SPOTfor Spot VMs.
- GPU_TYPE: the GPU type. You can view a list of the available GPU types by using the- gcloud compute accelerator-types listcommand. Only use this field for GPUs for N1 VMs.
- GPU_COUNT: the number of GPUs of the specified type. For more information about the valid options, see GPU machine types for N1 machine series. Only use this field for GPUs for N1 VMs.
- ALLOWED_LOCATIONS: You can optionally use the- allowedLocations[]field to specify a region or specific zone(s) in a region where the VMs for your job are allowed to run—for example,- regions/us-central1allows all zones in the region- us-central1. Make sure that you specify locations that offer the GPU machine type that you want for this job. Otherwise, if you omit this field, make sure the job's location offers the GPU machine type.
Java
Node.js
Python
What's next
- If you have issues creating or running a job, see Troubleshooting.
- View jobs and tasks.
- Learn about more job creation options.