Cluster Compute Configs
Cluster compute configs specify the resources your cluster will use. Cluster compute configs are optional, since Anyscale has defaults for all the values that the compute template can specify. Nevertheless, sometimes it's useful to specify some of the configs to override the default the values.
You might be familiar with Ray's cluster.yaml
, which specifies a large number of configs in a single file. Cluster compute configs are subset of this file.
Definition
The following is a fully-specified example of Cluster compute:
- AWS (Bring Your Own Cloud)
- GCP (Bring Your Own Cloud)
cloud: my-cloud # You may specify `cloud_id` instead
max_workers: 20
allowed_azs:
- us-west-2a
head_node_type:
name: head_node_type
instance_type: m5.2xlarge
worker_node_types:
- name: cpu_worker
instance_type: m5.4xlarge
min_workers: 2
max_workers: 10
use_spot: true
- name: gpu_worker
instance_type: g4dn.4xlarge
aws:
BlockDeviceMappings:
- DeviceName: "/dev/sda1"
Ebs:
VolumeSize: 50
DeleteOnTermination: true
IamInstanceProfile:
Arn: arn:aws:iam:etc
NetworkInterfaces:
- SubnetId: subnet-etc
Groups:
- sg-etc
AssociatePublicIpAddress: true
TagSpecifications:
- ResourceType: instance
Tags:
- Key: my-key
Value: my-value
cloud: my-cloud # You may specify `cloud_id` instead
max_workers: 20
allowed_azs:
- us-west-2a
head_node_type:
name: head_node_type
instance_type: n2-standard-8
worker_node_types:
- name: cpu_worker
instance_type: n2-standard-16
min_workers: 2
max_workers: 10
- name: gpu_worker
instance_type: n1-standard-16-nvidia-tesla-t4-1
Note that you can specify the following in your cluster compute configs:
- A cloud, which defaults to your default cloud (set by an organization owner for the entire organization). On the SDK, this can only be specified as
cloud_id
. On the CLI, you may specifycloud
(the cloud name) instead. The SDK example below show how to resolve acloud
into acloud_id
. - A maximum number of worker nodes to launch (defaults to infinity)
- A head node type, which defaults to
m5.2xlarge
on AWS orn2-standard-8
on GCP. - A list of worker node types, which by default includes:
- A CPU node type, which defaults to
m5.4xlarge
on AWS orn2-standard-16
on GCP. - A GPU node type, which defaults to
g4dn.4xlarge
on AWS orn1-standard-16-nvidia-tesla-t4-1
on GCP.
- A CPU node type, which defaults to
- AWS-specific configs, which are supported properties that will be passed directly to AWS when starting the instances (supported only when bringing your own cloud).
When specifying instance types, you may specify any instance type supported by Anyscale as detailed on this page. In addition to the instance type, node types allow you to specify:
- The node type name, which is used in logs.
- Spot instance usage, which defaults to
false
(supported only for worker node types when bringing your own AWS cloud). - A minimum and maximum number of workers, which default to 0 and infinity respectively (supported only for worker node types).
The advanced AWS-specific configuration (aws
block) is passed directly to the EC2 API when creating instances. You can use this to configure special parameters for your instances such as EBS disk size, security groups, and the subnet it resides in. We support the fields listed in the example, and the settings are applied to all instances launched for your cluster.
Please use caution when setting advanced AWS-specific configuration! Incorrect settings may cause your cluster to fail. The content of these fields is not validated before being passed to AWS.
Creating a cluster compute
You can use your cluster configs definition to create a cluster compute using the CLI, the Python SDK and the HTTP API:
- CLI
- Python SDK
anyscale cluster-compute create my_compute_configs.yaml --name my-cluster-compute
import yaml
from anyscale.sdk.anyscale_client.models import CreateClusterCompute
from anyscale import AnyscaleSDK
sdk = AnyscaleSDK()
with open('my_compute_configs.yaml') as f:
compute_configs = yaml.safe_load(f)
# If your config file contains `cloud`, use this to get the `cloud_id`
if "cloud" in compute_configs:
compute_configs["cloud_id"] = sdk.search_clouds(
{"name": {"equals": compute_configs["cloud"]}}
).results[0].id
del compute_configs["cloud"]
config=sdk.create_cluster_compute(CreateClusterCompute(
name="my-cluster-compute",
config=compute_configs
))
For more information, you can check the full reference of the CLI, Python SDK and the HTTP API.
You can also create a cluster compute in the Web UI by navigating to "Configurations > Cluster compute configs > Create a new config" to create a cluster compute config. You can also create one on the fly when you create a new cluster.