Skip to content

Commit

Permalink
feat(google_container_node_pool): support gpu driver version (#8348) (#…
Browse files Browse the repository at this point in the history
…15182)

Signed-off-by: toVersus <toversus2357@gmail.com>
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Jul 14, 2023
1 parent d2fde4f commit 73953ce
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/8348.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
container: added `gpu_driver_installation_config.gpu_driver_version` field to `google_container_node_pool`
```
3 changes: 3 additions & 0 deletions google/resource_container_node_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2456,6 +2456,9 @@ resource "google_container_node_pool" "np_with_gpu" {
type = "nvidia-tesla-a100"
gpu_partition_size = "1g.5gb"
count = 1
gpu_driver_installation_config {
gpu_driver_version = "LATEST"
}
gpu_sharing_config {
gpu_sharing_strategy = "TIME_SHARING"
max_shared_clients_per_gpu = 2
Expand Down
33 changes: 33 additions & 0 deletions google/services/container/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,25 @@ func schemaNodeConfig() *schema.Schema {
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
Description: `The accelerator type resource name.`,
},
"gpu_driver_installation_config": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
ForceNew: true,
ConfigMode: schema.SchemaConfigModeAttr,
Description: `Configuration for auto installation of GPU driver.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"gpu_driver_version": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: `Mode for how the GPU driver is installed.`,
ValidateFunc: validation.StringInSlice([]string{"GPU_DRIVER_VERSION_UNSPECIFIED", "INSTALLATION_DISABLED", "DEFAULT", "LATEST"}, false),
},
},
},
},
"gpu_partition_size": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -587,6 +606,13 @@ func expandNodeConfig(v interface{}) *container.NodeConfig {
GpuPartitionSize: data["gpu_partition_size"].(string),
}

if v, ok := data["gpu_driver_installation_config"]; ok && len(v.([]interface{})) > 0 {
gpuDriverInstallationConfig := data["gpu_driver_installation_config"].([]interface{})[0].(map[string]interface{})
guestAcceleratorConfig.GpuDriverInstallationConfig = &container.GPUDriverInstallationConfig{
GpuDriverVersion: gpuDriverInstallationConfig["gpu_driver_version"].(string),
}
}

if v, ok := data["gpu_sharing_config"]; ok && len(v.([]interface{})) > 0 {
gpuSharingConfig := data["gpu_sharing_config"].([]interface{})[0].(map[string]interface{})
guestAcceleratorConfig.GpuSharingConfig = &container.GPUSharingConfig{
Expand Down Expand Up @@ -956,6 +982,13 @@ func flattenContainerGuestAccelerators(c []*container.AcceleratorConfig) []map[s
"type": accel.AcceleratorType,
"gpu_partition_size": accel.GpuPartitionSize,
}
if accel.GpuDriverInstallationConfig != nil {
accelerator["gpu_driver_installation_config"] = []map[string]interface{}{
{
"gpu_driver_version": accel.GpuDriverInstallationConfig.GpuDriverVersion,
},
}
}
if accel.GpuSharingConfig != nil {
accelerator["gpu_sharing_config"] = []map[string]interface{}{
{
Expand Down
11 changes: 11 additions & 0 deletions website/docs/r/container_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,17 @@ sole_tenant_config {

* `count` (Required) - The number of the guest accelerator cards exposed to this instance.

* `gpu_driver_installation_config` (Optional) - Configuration for auto installation of GPU driver. Structure is [documented below](#nested_gpu_driver_installation_config).

<a name="nested_gpu_driver_installation_config"></a>The `gpu_driver_installation_config` block supports:

* `gpu_driver_version` (Required) - Mode for how the GPU driver is installed.
Accepted values are:
* `"GPU_DRIVER_VERSION_UNSPECIFIED"`: Default value is to not install any GPU driver.
* `"INSTALLATION_DISABLED"`: Disable GPU driver auto installation and needs manual installation.
* `"DEFAULT"`: "Default" GPU driver in COS and Ubuntu.
* `"LATEST"`: "Latest" GPU driver in COS.

* `gpu_partition_size` (Optional) - Size of partitions to create on the GPU. Valid values are described in the NVIDIA mig [user guide](https://docs.nvidia.com/datacenter/tesla/mig-user-guide/#partitioning).

* `gpu_sharing_config` (Optional) - Configuration for GPU sharing. Structure is [documented below](#nested_gpu_sharing_config).
Expand Down

0 comments on commit 73953ce

Please sign in to comment.