Reference documentation and code samples for the Google Cloud Batch V1 Client class ComputeResource.
Compute resource requirements.
ComputeResource defines the amount of resources required for each task.
Make sure your tasks have enough resources to successfully run.
If you also define the types of resources for a job to use with theInstancePolicyOrTemplatefield, make sure both fields are compatible with each other.
Generated from protobuf messagegoogle.cloud.batch.v1.ComputeResource
Namespace
Google \ Cloud \ Batch \ V1
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ cpu_milli
int|string
The milliCPU count.cpuMillidefines the amount of CPU resources per task in milliCPU units. For example,1000corresponds to 1 vCPU per task. If undefined, the default value is2000. If you also define the VM's machine type using themachineTypeinInstancePolicyfield or inside theinstanceTemplatein theInstancePolicyOrTemplatefield, make sure the CPU resources for both fields are compatible with each other and with how many tasks you want to allow to run on the same VM at the same time. For example, if you specify then2-standard-2machine type, which has 2 vCPUs each, you are recommended to setcpuMillino more than2000, or you are recommended to run two tasks on the same VM if you setcpuMillito1000or less.
↳ memory_mib
int|string
Memory in MiB.memoryMibdefines the amount of memory per task in MiB units. If undefined, the default value is2000. If you also define the VM's machine type using themachineTypeinInstancePolicyfield or inside theinstanceTemplatein theInstancePolicyOrTemplatefield, make sure the memory resources for both fields are compatible with each other and with how many tasks you want to allow to run on the same VM at the same time. For example, if you specify then2-standard-2machine type, which has 8 GiB each, you are recommended to setmemoryMibto no more than8192, or you are recommended to run two tasks on the same VM if you setmemoryMibto4096or less.
↳ boot_disk_mib
int|string
Extra boot disk size in MiB for each task.
getCpuMilli
The milliCPU count.
cpuMillidefines the amount of CPU resources per task in milliCPU units.
For example,1000corresponds to 1 vCPU per task. If undefined, the
default value is2000.
If you also define the VM's machine type using themachineTypeinInstancePolicyfield or inside theinstanceTemplatein theInstancePolicyOrTemplatefield, make sure the CPU resources for both fields are compatible with each
other and with how many tasks you want to allow to run on the same VM at
the same time.
For example, if you specify then2-standard-2machine type, which has 2
vCPUs each, you are recommended to setcpuMillino more than2000, or
you are recommended to run two tasks on the same VM if you setcpuMillito1000or less.
Returns
Type
Description
int|string
setCpuMilli
The milliCPU count.
cpuMillidefines the amount of CPU resources per task in milliCPU units.
For example,1000corresponds to 1 vCPU per task. If undefined, the
default value is2000.
If you also define the VM's machine type using themachineTypeinInstancePolicyfield or inside theinstanceTemplatein theInstancePolicyOrTemplatefield, make sure the CPU resources for both fields are compatible with each
other and with how many tasks you want to allow to run on the same VM at
the same time.
For example, if you specify then2-standard-2machine type, which has 2
vCPUs each, you are recommended to setcpuMillino more than2000, or
you are recommended to run two tasks on the same VM if you setcpuMillito1000or less.
Parameter
Name
Description
var
int|string
Returns
Type
Description
$this
getMemoryMib
Memory in MiB.
memoryMibdefines the amount of memory per task in MiB units.
If undefined, the default value is2000.
If you also define the VM's machine type using themachineTypeinInstancePolicyfield or inside theinstanceTemplatein theInstancePolicyOrTemplatefield, make sure the memory resources for both fields are compatible with
each other and with how many tasks you want to allow to run on the same VM
at the same time.
For example, if you specify then2-standard-2machine type, which has 8
GiB each, you are recommended to setmemoryMibto no more than8192,
or you are recommended to run two tasks on the same VM if you setmemoryMibto4096or less.
Returns
Type
Description
int|string
setMemoryMib
Memory in MiB.
memoryMibdefines the amount of memory per task in MiB units.
If undefined, the default value is2000.
If you also define the VM's machine type using themachineTypeinInstancePolicyfield or inside theinstanceTemplatein theInstancePolicyOrTemplatefield, make sure the memory resources for both fields are compatible with
each other and with how many tasks you want to allow to run on the same VM
at the same time.
For example, if you specify then2-standard-2machine type, which has 8
GiB each, you are recommended to setmemoryMibto no more than8192,
or you are recommended to run two tasks on the same VM if you setmemoryMibto4096or less.
[[["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-09-04 UTC."],[],[],null,["# Google Cloud Batch V1 Client - Class ComputeResource (1.2.2)\n\nVersion latestkeyboard_arrow_down\n\n- [1.2.2 (latest)](/php/docs/reference/cloud-batch/latest/V1.ComputeResource)\n- [1.2.1](/php/docs/reference/cloud-batch/1.2.1/V1.ComputeResource)\n- [1.1.7](/php/docs/reference/cloud-batch/1.1.7/V1.ComputeResource)\n- [1.0.3](/php/docs/reference/cloud-batch/1.0.3/V1.ComputeResource)\n- [0.17.0](/php/docs/reference/cloud-batch/0.17.0/V1.ComputeResource)\n- [0.16.10](/php/docs/reference/cloud-batch/0.16.10/V1.ComputeResource)\n- [0.15.0](/php/docs/reference/cloud-batch/0.15.0/V1.ComputeResource)\n- [0.14.0](/php/docs/reference/cloud-batch/0.14.0/V1.ComputeResource)\n- [0.13.1](/php/docs/reference/cloud-batch/0.13.1/V1.ComputeResource)\n- [0.12.1](/php/docs/reference/cloud-batch/0.12.1/V1.ComputeResource)\n- [0.11.3](/php/docs/reference/cloud-batch/0.11.3/V1.ComputeResource)\n- [0.10.0](/php/docs/reference/cloud-batch/0.10.0/V1.ComputeResource)\n- [0.9.0](/php/docs/reference/cloud-batch/0.9.0/V1.ComputeResource)\n- [0.8.0](/php/docs/reference/cloud-batch/0.8.0/V1.ComputeResource)\n- [0.7.0](/php/docs/reference/cloud-batch/0.7.0/V1.ComputeResource)\n- [0.6.0](/php/docs/reference/cloud-batch/0.6.0/V1.ComputeResource)\n- [0.5.2](/php/docs/reference/cloud-batch/0.5.2/V1.ComputeResource)\n- [0.4.0](/php/docs/reference/cloud-batch/0.4.0/V1.ComputeResource)\n- [0.3.0](/php/docs/reference/cloud-batch/0.3.0/V1.ComputeResource)\n- [0.2.2](/php/docs/reference/cloud-batch/0.2.2/V1.ComputeResource) \nReference documentation and code samples for the Google Cloud Batch V1 Client class ComputeResource.\n\nCompute resource requirements.\n\nComputeResource defines the amount of resources required for each task.\nMake sure your tasks have enough resources to successfully run.\nIf you also define the types of resources for a job to use with the\n[InstancePolicyOrTemplate](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicyortemplate)\nfield, make sure both fields are compatible with each other.\n\nGenerated from protobuf message `google.cloud.batch.v1.ComputeResource`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Batch \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getCpuMilli\n\nThe milliCPU count.\n\n`cpuMilli` defines the amount of CPU resources per task in milliCPU units.\nFor example, `1000` corresponds to 1 vCPU per task. If undefined, the\ndefault value is `2000`.\nIf you also define the VM's machine type using the `machineType` in\n[InstancePolicy](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicy)\nfield or inside the `instanceTemplate` in the\n[InstancePolicyOrTemplate](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicyortemplate)\nfield, make sure the CPU resources for both fields are compatible with each\nother and with how many tasks you want to allow to run on the same VM at\nthe same time.\nFor example, if you specify the `n2-standard-2` machine type, which has 2\nvCPUs each, you are recommended to set `cpuMilli` no more than `2000`, or\nyou are recommended to run two tasks on the same VM if you set `cpuMilli`\nto `1000` or less.\n\n### setCpuMilli\n\nThe milliCPU count.\n\n`cpuMilli` defines the amount of CPU resources per task in milliCPU units.\nFor example, `1000` corresponds to 1 vCPU per task. If undefined, the\ndefault value is `2000`.\nIf you also define the VM's machine type using the `machineType` in\n[InstancePolicy](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicy)\nfield or inside the `instanceTemplate` in the\n[InstancePolicyOrTemplate](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicyortemplate)\nfield, make sure the CPU resources for both fields are compatible with each\nother and with how many tasks you want to allow to run on the same VM at\nthe same time.\nFor example, if you specify the `n2-standard-2` machine type, which has 2\nvCPUs each, you are recommended to set `cpuMilli` no more than `2000`, or\nyou are recommended to run two tasks on the same VM if you set `cpuMilli`\nto `1000` or less.\n\n### getMemoryMib\n\nMemory in MiB.\n\n`memoryMib` defines the amount of memory per task in MiB units.\nIf undefined, the default value is `2000`.\nIf you also define the VM's machine type using the `machineType` in\n[InstancePolicy](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicy)\nfield or inside the `instanceTemplate` in the\n[InstancePolicyOrTemplate](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicyortemplate)\nfield, make sure the memory resources for both fields are compatible with\neach other and with how many tasks you want to allow to run on the same VM\nat the same time.\nFor example, if you specify the `n2-standard-2` machine type, which has 8\nGiB each, you are recommended to set `memoryMib` to no more than `8192`,\nor you are recommended to run two tasks on the same VM if you set\n`memoryMib` to `4096` or less.\n\n### setMemoryMib\n\nMemory in MiB.\n\n`memoryMib` defines the amount of memory per task in MiB units.\nIf undefined, the default value is `2000`.\nIf you also define the VM's machine type using the `machineType` in\n[InstancePolicy](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicy)\nfield or inside the `instanceTemplate` in the\n[InstancePolicyOrTemplate](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicyortemplate)\nfield, make sure the memory resources for both fields are compatible with\neach other and with how many tasks you want to allow to run on the same VM\nat the same time.\nFor example, if you specify the `n2-standard-2` machine type, which has 8\nGiB each, you are recommended to set `memoryMib` to no more than `8192`,\nor you are recommended to run two tasks on the same VM if you set\n`memoryMib` to `4096` or less.\n\n### getBootDiskMib\n\nExtra boot disk size in MiB for each task.\n\n### setBootDiskMib\n\nExtra boot disk size in MiB for each task."]]