public sealed class ComputeResource : IMessage<ComputeResource>, IEquatable<ComputeResource>, IDeepCloneable<ComputeResource>, IBufferMessage, IMessage
Reference documentation and code samples for the Batch v1alpha API 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 the
InstancePolicyOrTemplate
field, make sure both fields are compatible with each other.
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.
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"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eComputeResource\u003c/code\u003e class in the Batch v1alpha API defines the resource requirements for each task, such as CPU, memory, and boot disk size.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eComputeResource\u003c/code\u003e class implements interfaces including \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e, and inherits from \u003ccode\u003eobject\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eCpuMilli\u003c/code\u003e property defines the CPU resources per task in milliCPU units, with a default of 2000 if undefined, and it should be compatible with any defined machine types.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eMemoryMib\u003c/code\u003e property defines the memory per task in MiB units, with a default of 2000 if undefined, and should be compatible with any defined machine types.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eBootDiskMib\u003c/code\u003e property allows the user to define extra boot disk size in MiB for each task.\u003c/p\u003e\n"]]],[],null,["# Batch v1alpha API - Class ComputeResource (1.0.0-alpha31)\n\nVersion latestkeyboard_arrow_down\n\n- [1.0.0-alpha31 (latest)](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha.ComputeResource)\n- [1.0.0-alpha30](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/1.0.0-alpha30/Google.Cloud.Batch.V1Alpha.ComputeResource) \n\n public sealed class ComputeResource : IMessage\u003cComputeResource\u003e, IEquatable\u003cComputeResource\u003e, IDeepCloneable\u003cComputeResource\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Batch v1alpha API 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\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e ComputeResource \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[ComputeResource](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha.ComputeResource), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[ComputeResource](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha.ComputeResource), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[ComputeResource](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha.ComputeResource), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Batch.V1Alpha](/dotnet/docs/reference/Google.Cloud.Batch.V1Alpha/latest/Google.Cloud.Batch.V1Alpha)\n\nAssembly\n--------\n\nGoogle.Cloud.Batch.V1Alpha.dll\n\nConstructors\n------------\n\n### ComputeResource()\n\n public ComputeResource()\n\n### ComputeResource(ComputeResource)\n\n public ComputeResource(ComputeResource other)\n\nProperties\n----------\n\n### BootDiskMib\n\n public long BootDiskMib { get; set; }\n\nExtra boot disk size in MiB for each task.\n\n### CpuMilli\n\n public long CpuMilli { get; set; }\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`.\n\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.\n\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### GpuCount\n\n public long GpuCount { get; set; }\n\nThe GPU count.\n\nNot yet implemented.\n\n### MemoryMib\n\n public long MemoryMib { get; set; }\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.\n\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."]]