diff --git a/README.md b/README.md index 67c7a5f..7d1f56f 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 (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' @@ -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..86ac536 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")