Reference documentation and code samples for the Batch V1 API class Google::Cloud::Batch::V1::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 the
InstancePolicyOrTemplate
field, make sure both fields are compatible with each other.
Inherits
Object
Extended By
Google::Protobuf::MessageExts::ClassMethods
Includes
Google::Protobuf::MessageExts
Methods
#boot_disk_mib
defboot_disk_mib()->::Integer
Returns
(::Integer) — Extra boot disk size in MiB for each task.
#boot_disk_mib=
defboot_disk_mib=(value)->::Integer
Parameter
value (::Integer) — Extra boot disk size in MiB for each task.
Returns
(::Integer) — Extra boot disk size in MiB for each task.
#cpu_milli
defcpu_milli()->::Integer
Returns
(::Integer) — The milliCPU count.
cpuMilli defines the amount of CPU resources per task in milliCPU units.
For example, 1000 corresponds to 1 vCPU per task. If undefined, the
default value is 2000.
If you also define the VM's machine type using the machineType in
InstancePolicy
field or inside the instanceTemplate in the
InstancePolicyOrTemplate
field, 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 the n2-standard-2 machine type, which has 2
vCPUs each, you are recommended to set cpuMilli no more than 2000, or
you are recommended to run two tasks on the same VM if you set cpuMilli
to 1000 or less.
#cpu_milli=
defcpu_milli=(value)->::Integer
Parameter
value (::Integer) — The milliCPU count.
cpuMilli defines the amount of CPU resources per task in milliCPU units.
For example, 1000 corresponds to 1 vCPU per task. If undefined, the
default value is 2000.
If you also define the VM's machine type using the machineType in
InstancePolicy
field or inside the instanceTemplate in the
InstancePolicyOrTemplate
field, 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 the n2-standard-2 machine type, which has 2
vCPUs each, you are recommended to set cpuMilli no more than 2000, or
you are recommended to run two tasks on the same VM if you set cpuMilli
to 1000 or less.
Returns
(::Integer) — The milliCPU count.
cpuMilli defines the amount of CPU resources per task in milliCPU units.
For example, 1000 corresponds to 1 vCPU per task. If undefined, the
default value is 2000.
If you also define the VM's machine type using the machineType in
InstancePolicy
field or inside the instanceTemplate in the
InstancePolicyOrTemplate
field, 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 the n2-standard-2 machine type, which has 2
vCPUs each, you are recommended to set cpuMilli no more than 2000, or
you are recommended to run two tasks on the same VM if you set cpuMilli
to 1000 or less.
#memory_mib
defmemory_mib()->::Integer
Returns
(::Integer) — Memory in MiB.
memoryMib defines the amount of memory per task in MiB units.
If undefined, the default value is 2000.
If you also define the VM's machine type using the machineType in
InstancePolicy
field or inside the instanceTemplate in the
InstancePolicyOrTemplate
field, 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 the n2-standard-2 machine type, which has 8
GiB each, you are recommended to set memoryMib to no more than 8192,
or you are recommended to run two tasks on the same VM if you set
memoryMib to 4096 or less.
#memory_mib=
defmemory_mib=(value)->::Integer
Parameter
value (::Integer) — Memory in MiB.
memoryMib defines the amount of memory per task in MiB units.
If undefined, the default value is 2000.
If you also define the VM's machine type using the machineType in
InstancePolicy
field or inside the instanceTemplate in the
InstancePolicyOrTemplate
field, 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 the n2-standard-2 machine type, which has 8
GiB each, you are recommended to set memoryMib to no more than 8192,
or you are recommended to run two tasks on the same VM if you set
memoryMib to 4096 or less.
Returns
(::Integer) — Memory in MiB.
memoryMib defines the amount of memory per task in MiB units.
If undefined, the default value is 2000.
If you also define the VM's machine type using the machineType in
InstancePolicy
field or inside the instanceTemplate in the
InstancePolicyOrTemplate
field, 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 the n2-standard-2 machine type, which has 8
GiB each, you are recommended to set memoryMib to no more than 8192,
or you are recommended to run two tasks on the same VM if you set
memoryMib to 4096 or 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-09 UTC."],[],[],null,["# Batch V1 API - Class Google::Cloud::Batch::V1::ComputeResource (v1.2.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.2.0 (latest)](/ruby/docs/reference/google-cloud-batch-v1/latest/Google-Cloud-Batch-V1-ComputeResource)\n- [1.1.1](/ruby/docs/reference/google-cloud-batch-v1/1.1.1/Google-Cloud-Batch-V1-ComputeResource)\n- [1.0.0](/ruby/docs/reference/google-cloud-batch-v1/1.0.0/Google-Cloud-Batch-V1-ComputeResource)\n- [0.21.0](/ruby/docs/reference/google-cloud-batch-v1/0.21.0/Google-Cloud-Batch-V1-ComputeResource)\n- [0.20.1](/ruby/docs/reference/google-cloud-batch-v1/0.20.1/Google-Cloud-Batch-V1-ComputeResource)\n- [0.19.2](/ruby/docs/reference/google-cloud-batch-v1/0.19.2/Google-Cloud-Batch-V1-ComputeResource)\n- [0.18.3](/ruby/docs/reference/google-cloud-batch-v1/0.18.3/Google-Cloud-Batch-V1-ComputeResource)\n- [0.17.4](/ruby/docs/reference/google-cloud-batch-v1/0.17.4/Google-Cloud-Batch-V1-ComputeResource)\n- [0.16.2](/ruby/docs/reference/google-cloud-batch-v1/0.16.2/Google-Cloud-Batch-V1-ComputeResource)\n- [0.15.1](/ruby/docs/reference/google-cloud-batch-v1/0.15.1/Google-Cloud-Batch-V1-ComputeResource)\n- [0.14.0](/ruby/docs/reference/google-cloud-batch-v1/0.14.0/Google-Cloud-Batch-V1-ComputeResource)\n- [0.13.1](/ruby/docs/reference/google-cloud-batch-v1/0.13.1/Google-Cloud-Batch-V1-ComputeResource)\n- [0.12.0](/ruby/docs/reference/google-cloud-batch-v1/0.12.0/Google-Cloud-Batch-V1-ComputeResource)\n- [0.11.1](/ruby/docs/reference/google-cloud-batch-v1/0.11.1/Google-Cloud-Batch-V1-ComputeResource)\n- [0.10.5](/ruby/docs/reference/google-cloud-batch-v1/0.10.5/Google-Cloud-Batch-V1-ComputeResource)\n- [0.9.0](/ruby/docs/reference/google-cloud-batch-v1/0.9.0/Google-Cloud-Batch-V1-ComputeResource)\n- [0.8.0](/ruby/docs/reference/google-cloud-batch-v1/0.8.0/Google-Cloud-Batch-V1-ComputeResource)\n- [0.7.0](/ruby/docs/reference/google-cloud-batch-v1/0.7.0/Google-Cloud-Batch-V1-ComputeResource)\n- [0.6.0](/ruby/docs/reference/google-cloud-batch-v1/0.6.0/Google-Cloud-Batch-V1-ComputeResource)\n- [0.5.0](/ruby/docs/reference/google-cloud-batch-v1/0.5.0/Google-Cloud-Batch-V1-ComputeResource)\n- [0.4.3](/ruby/docs/reference/google-cloud-batch-v1/0.4.3/Google-Cloud-Batch-V1-ComputeResource)\n- [0.3.0](/ruby/docs/reference/google-cloud-batch-v1/0.3.0/Google-Cloud-Batch-V1-ComputeResource)\n- [0.2.0](/ruby/docs/reference/google-cloud-batch-v1/0.2.0/Google-Cloud-Batch-V1-ComputeResource)\n- [0.1.0](/ruby/docs/reference/google-cloud-batch-v1/0.1.0/Google-Cloud-Batch-V1-ComputeResource) \nReference documentation and code samples for the Batch V1 API class Google::Cloud::Batch::V1::ComputeResource.\n\nCompute resource requirements.\n\n\n\u003cbr /\u003e\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\nInherits\n--------\n\n- Object \n\nExtended By\n-----------\n\n- Google::Protobuf::MessageExts::ClassMethods \n\nIncludes\n--------\n\n- Google::Protobuf::MessageExts\n\nMethods\n-------\n\n### #boot_disk_mib\n\n def boot_disk_mib() -\u003e ::Integer\n\n**Returns**\n\n- (::Integer) --- Extra boot disk size in MiB for each task.\n\n### #boot_disk_mib=\n\n def boot_disk_mib=(value) -\u003e ::Integer\n\n**Parameter**\n\n- **value** (::Integer) --- Extra boot disk size in MiB for each task. \n**Returns**\n\n- (::Integer) --- Extra boot disk size in MiB for each task.\n\n### #cpu_milli\n\n def cpu_milli() -\u003e ::Integer\n\n**Returns**\n\n- (::Integer) --- The milliCPU count.\n\n `cpuMilli` defines the amount of CPU resources per task in milliCPU units.\n For example, `1000` corresponds to 1 vCPU per task. If undefined, the\n default value is `2000`.\n\n If 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)\n field or inside the `instanceTemplate` in the\n [InstancePolicyOrTemplate](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicyortemplate)\n field, make sure the CPU resources for both fields are compatible with each\n other and with how many tasks you want to allow to run on the same VM at\n the same time.\n\n For example, if you specify the `n2-standard-2` machine type, which has 2\n vCPUs each, you are recommended to set `cpuMilli` no more than `2000`, or\n you are recommended to run two tasks on the same VM if you set `cpuMilli`\n to `1000` or less.\n\n### #cpu_milli=\n\n def cpu_milli=(value) -\u003e ::Integer\n\n**Parameter**\n\n- **value** (::Integer) --- The milliCPU count.\n\n\n `cpuMilli` defines the amount of CPU resources per task in milliCPU units.\n For example, `1000` corresponds to 1 vCPU per task. If undefined, the\n default value is `2000`.\n\n If 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)\n field or inside the `instanceTemplate` in the\n [InstancePolicyOrTemplate](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicyortemplate)\n field, make sure the CPU resources for both fields are compatible with each\n other and with how many tasks you want to allow to run on the same VM at\n the same time.\n\n For example, if you specify the `n2-standard-2` machine type, which has 2\n vCPUs each, you are recommended to set `cpuMilli` no more than `2000`, or\n you are recommended to run two tasks on the same VM if you set `cpuMilli`\nto `1000` or less. \n**Returns**\n\n- (::Integer) --- The milliCPU count.\n\n `cpuMilli` defines the amount of CPU resources per task in milliCPU units.\n For example, `1000` corresponds to 1 vCPU per task. If undefined, the\n default value is `2000`.\n\n If 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)\n field or inside the `instanceTemplate` in the\n [InstancePolicyOrTemplate](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicyortemplate)\n field, make sure the CPU resources for both fields are compatible with each\n other and with how many tasks you want to allow to run on the same VM at\n the same time.\n\n For example, if you specify the `n2-standard-2` machine type, which has 2\n vCPUs each, you are recommended to set `cpuMilli` no more than `2000`, or\n you are recommended to run two tasks on the same VM if you set `cpuMilli`\n to `1000` or less.\n\n### #memory_mib\n\n def memory_mib() -\u003e ::Integer\n\n**Returns**\n\n- (::Integer) --- Memory in MiB.\n\n `memoryMib` defines the amount of memory per task in MiB units.\n If undefined, the default value is `2000`.\n If 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)\n field or inside the `instanceTemplate` in the\n [InstancePolicyOrTemplate](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicyortemplate)\n field, make sure the memory resources for both fields are compatible with\n each other and with how many tasks you want to allow to run on the same VM\n at the same time.\n\n For example, if you specify the `n2-standard-2` machine type, which has 8\n GiB each, you are recommended to set `memoryMib` to no more than `8192`,\n or you are recommended to run two tasks on the same VM if you set\n `memoryMib` to `4096` or less.\n\n### #memory_mib=\n\n def memory_mib=(value) -\u003e ::Integer\n\n**Parameter**\n\n- **value** (::Integer) --- Memory in MiB.\n\n\n `memoryMib` defines the amount of memory per task in MiB units.\n If undefined, the default value is `2000`.\n If 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)\n field or inside the `instanceTemplate` in the\n [InstancePolicyOrTemplate](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicyortemplate)\n field, make sure the memory resources for both fields are compatible with\n each other and with how many tasks you want to allow to run on the same VM\n at the same time.\n\n For example, if you specify the `n2-standard-2` machine type, which has 8\n GiB each, you are recommended to set `memoryMib` to no more than `8192`,\n or you are recommended to run two tasks on the same VM if you set\n`memoryMib` to `4096` or less. \n**Returns**\n\n- (::Integer) --- Memory in MiB.\n\n `memoryMib` defines the amount of memory per task in MiB units.\n If undefined, the default value is `2000`.\n If 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)\n field or inside the `instanceTemplate` in the\n [InstancePolicyOrTemplate](https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#instancepolicyortemplate)\n field, make sure the memory resources for both fields are compatible with\n each other and with how many tasks you want to allow to run on the same VM\n at the same time.\n\n For example, if you specify the `n2-standard-2` machine type, which has 8\n GiB each, you are recommended to set `memoryMib` to no more than `8192`,\n or you are recommended to run two tasks on the same VM if you set\n `memoryMib` to `4096` or less."]]