From 000ec83c15fee4bc35ce465afb26911f89a92fc0 Mon Sep 17 00:00:00 2001 From: Petr Artamonov Date: Thu, 21 Mar 2024 10:54:19 +0300 Subject: [PATCH 1/7] add_gpu_support --- README.md | 2 ++ driver/client.go | 1 + driver/driver.go | 10 ++++++++++ 3 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 67c7a5f..899d07e 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ If you haven't specified yc-token nor yc-service-account-key-file it will try to - `--yandex-cloud-id`: Cloud ID - `--yandex-cores`: Count of virtual CPUs +- `--yandex-gpus`: Count of virtual GPUs - `--yandex-core-fraction`: Core fraction - `--yandex-disk-size`: Disk size in gigabytes - `--yandex-disk-type`: Disk type, e.g. 'network-hdd' @@ -69,6 +70,7 @@ If you haven't specified yc-token nor yc-service-account-key-file it will try to |----------------------------|----------------------|--------------------------| | `--yandex-cloud-id` | YC_CLOUD_ID | | | `--yandex-cores` | YC_CORES | 2 | +| `--yandex-gpus` | YC_GPUS | 0 | | `--yandex-core-fraction` | YC_CORE_FRACTION | 100 | | `--yandex-disk-size` | YC_DISK_SIZE | 20 | | `--yandex-disk-type` | YC_DISK_TYPE | network-hdd | diff --git a/driver/client.go b/driver/client.go index 598ae61..c1a5d52 100644 --- a/driver/client.go +++ b/driver/client.go @@ -90,6 +90,7 @@ func prepareInstanceCreateRequest(d *Driver, imageID string) *compute.CreateInst PlatformId: d.PlatformID, ResourcesSpec: &compute.ResourcesSpec{ Cores: int64(d.Cores), + Gpus: int64(d.Gpus), CoreFraction: int64(d.CoreFraction), Memory: toBytes(d.Memory), }, diff --git a/driver/driver.go b/driver/driver.go index 3d67bbc..a53a603 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -32,6 +32,7 @@ type Driver struct { CloudID string Cores int + Gpus int CoreFraction int DiskSize int DiskType string @@ -59,6 +60,7 @@ type Driver struct { } const ( + defaultGpus = 0 defaultCores = 2 defaultCoreFraction = 100 defaultDiskSize = 20 @@ -77,6 +79,7 @@ func NewDriver() drivers.Driver { return &Driver{ BaseDriver: &drivers.BaseDriver{}, Cores: defaultCores, + Gpus: defaultGpus, DiskSize: defaultDiskSize, DiskType: defaultDiskType, ImageFolderID: defaultImageFolderID, @@ -105,6 +108,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { Usage: "Count of virtual CPUs", Value: defaultCores, }, + mcnflag.IntFlag{ + EnvVar: "YC_GPUS", + Name: "yandex-gpus", + Usage: "Count of virtual GPUs", + Value: defaultGpus, + }, mcnflag.IntFlag{ EnvVar: "YC_CORE_FRACTION", Name: "yandex-core-fraction", @@ -254,6 +263,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { d.Token = flags.String("yandex-token") d.Cores = flags.Int("yandex-cores") + d.Gpus = flags.Int("yandex-gpus") d.CoreFraction = flags.Int("yandex-core-fraction") d.DiskSize = flags.Int("yandex-disk-size") d.DiskType = flags.String("yandex-disk-type") From 7d72f83ba8f601696e0bcb6620204b1801082b6a Mon Sep 17 00:00:00 2001 From: "petr.artamonov" Date: Mon, 1 Apr 2024 12:19:45 +0300 Subject: [PATCH 2/7] add_gpu --- driver/driver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/driver.go b/driver/driver.go index a53a603..86ac536 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -60,7 +60,7 @@ type Driver struct { } const ( - defaultGpus = 0 + defaultGpus = 0 defaultCores = 2 defaultCoreFraction = 100 defaultDiskSize = 20 From 83b9d4267879e9f2febbe2215a4bc6dc9743d6de Mon Sep 17 00:00:00 2001 From: "petr.artamonov" Date: Mon, 1 Apr 2024 12:20:57 +0300 Subject: [PATCH 3/7] add_gpu --- driver/driver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/driver.go b/driver/driver.go index 86ac536..69fe451 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -79,7 +79,7 @@ func NewDriver() drivers.Driver { return &Driver{ BaseDriver: &drivers.BaseDriver{}, Cores: defaultCores, - Gpus: defaultGpus, + Gpus: defaultGpus, DiskSize: defaultDiskSize, DiskType: defaultDiskType, ImageFolderID: defaultImageFolderID, From c0a75f52543746efbc6dcb857b84546a1cfbcecd Mon Sep 17 00:00:00 2001 From: "petr.artamonov" Date: Mon, 1 Apr 2024 12:21:34 +0300 Subject: [PATCH 4/7] add_gpu --- driver/driver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/driver.go b/driver/driver.go index 69fe451..0f9e8d8 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -79,7 +79,7 @@ func NewDriver() drivers.Driver { return &Driver{ BaseDriver: &drivers.BaseDriver{}, Cores: defaultCores, - Gpus: defaultGpus, + Gpus: defaultGpus, DiskSize: defaultDiskSize, DiskType: defaultDiskType, ImageFolderID: defaultImageFolderID, From 5951c61be0b2cee09effc19bc4096c7a05c86b7c Mon Sep 17 00:00:00 2001 From: "petr.artamonov" Date: Mon, 1 Apr 2024 12:21:55 +0300 Subject: [PATCH 5/7] add_gpu --- driver/driver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/driver.go b/driver/driver.go index 0f9e8d8..9da7715 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -79,7 +79,7 @@ func NewDriver() drivers.Driver { return &Driver{ BaseDriver: &drivers.BaseDriver{}, Cores: defaultCores, - Gpus: defaultGpus, + Gpus: defaultGpus, DiskSize: defaultDiskSize, DiskType: defaultDiskType, ImageFolderID: defaultImageFolderID, From a926fe5ea2b91c78cb188d501a195d6e362cc953 Mon Sep 17 00:00:00 2001 From: "petr.artamonov" Date: Mon, 1 Apr 2024 12:22:28 +0300 Subject: [PATCH 6/7] add_gpu --- driver/driver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/driver.go b/driver/driver.go index 9da7715..86ac536 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -79,7 +79,7 @@ func NewDriver() drivers.Driver { return &Driver{ BaseDriver: &drivers.BaseDriver{}, Cores: defaultCores, - Gpus: defaultGpus, + Gpus: defaultGpus, DiskSize: defaultDiskSize, DiskType: defaultDiskType, ImageFolderID: defaultImageFolderID, From 9a6126287579c7186184da984a709f52fd78c131 Mon Sep 17 00:00:00 2001 From: "petr.artamonov" Date: Mon, 1 Apr 2024 12:23:51 +0300 Subject: [PATCH 7/7] add_gpu --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 899d07e..7d1f56f 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ If you haven't specified yc-token nor yc-service-account-key-file it will try to - `--yandex-cloud-id`: Cloud ID - `--yandex-cores`: Count of virtual CPUs -- `--yandex-gpus`: Count of virtual GPUs +- `--yandex-gpus`: Count of virtual GPUs (Highly recommend use with image family "container-optimized-image-gpu") - `--yandex-core-fraction`: Core fraction - `--yandex-disk-size`: Disk size in gigabytes - `--yandex-disk-type`: Disk type, e.g. 'network-hdd'