compute#
- class cloudly.gcp.compute.Instance[source]#
Bases:
object- classmethod create(config: InstanceConfig | dict) Instance[source]#
- __init__(name: str, zone: str)[source]#
name is either the “Name” or “Instance Id” shown on GCP dashboard.
- property id: int#
- property machine_type: str#
- property gpu: dict#
- property disks: list[dict]#
- property creation_timestamp: str#
- property last_start_timestamp: str#
- property last_stop_timestamp: str#
- property ip: str#
- class cloudly.gcp.compute.InstanceConfig[source]#
Bases:
object- class BootDisk[source]#
Bases:
object- __init__(*, size_gb: int = 50, source_image: str = 'projects/debian-cloud/global/images/family/debian-11')[source]#
- property startup_script: str#
- class LocalSSD[source]#
Bases:
object- __init__(*, size_gb: int, mount_path: str = '/mnt', mode: str = 'rw')[source]#
size_gb should be a multiple of 375. If not, the next greater multiple of 375 will be used.
- property startup_script: str#
- class GPU[source]#
Bases:
object
- __init__(*, name: str, zone: str, machine_type: str, labels: dict[str, str] | None = None, boot_disk: dict | None = None, local_ssd: dict | None = None, network_uri: str | None = None, subnet_uri: str | None = None, startup_script: str | None = None, gpu: dict | None = None)[source]#
name is a “display name”, but also plays the role of an ID because it must be unique for the project in the specified region.
name must be 1-63 characters long and match the regular expression
[a-z]([-a-z0-9]*[a-z0-9])?which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.zone is like ‘us-west1-a’.
machine_type: cheap, low-end machines suitable for lightweights tests:
‘t2a-standard-1’ (1 CPU 4 GiB, $0.0385 / hour) ‘t2d-standard-1’ (1 CPU 4 GiB, $0.0422 / hour) ‘c4a-standard-1’ (1 CPU 4 GiB, $0.0449 / hour) ‘n1-standard-1’ (1 CPU 3.75 GiB, $0.0475 / hour) ‘e2-standard-2’ (2 CPUs 8 GiB, $0.067 / hour) ‘n2d-standard-2’ (2 CPUs 8 GiB, $0.084 / hour) ‘n4-standard-2’ (2 CPUs 8 GiB, $0.0948 / hour) ‘n2-standard-2’ (2 CPUs 8 GiB, $0.097 / hour) ‘e2-standard-4’ (4 CPUs 16 GiB, $0.134 / hour) ‘e2-standard-8’ (8 CPUs 32 GiB, $0.27 / hour)
See https://cloud.google.com/compute/all-pricing?hl=en
network_uri may look like “projects/shared-vpc-admin/global/networks/vpcnet-shared-prod-01”. subnet_uri may look like “https://www.googleapis.com/compute/v1/projects/shared-vpc-admin/regions/<region>/subnetworks/prod-<region>-01”. If None, the project’s default network and subnet (for the specified region) will be used. See https://cloud.google.com/compute/docs/networking/network-overview
startup_script: shell script that installs software and makes any other preps before the instance becomes operational. If provided, this must handle everything, as the script will not be augmented in this function. Common concerns include mounting local disks and installing cuda drivers (if you attach GPUs).
There are some restrictions to the label values. See https://cloud.google.com/batch/docs/organize-resources-using-labels
- property instance: Instance#
- property definition: dict#