setup_global_ray_cluster#
- ray.util.spark.setup_global_ray_cluster(*, max_worker_nodes: int, is_blocking: bool = True, min_worker_nodes: int | None = None, num_cpus_worker_node: int | None = None, num_cpus_head_node: int | None = None, num_gpus_worker_node: int | None = None, num_gpus_head_node: int | None = None, memory_worker_node: int | None = None, memory_head_node: int | None = None, object_store_memory_worker_node: int | None = None, object_store_memory_head_node: int | None = None, head_node_options: Dict | None = None, worker_node_options: Dict | None = None, strict_mode: bool = False, collect_log_to_path: str | None = None, autoscale_upscaling_speed: float | None = 1.0, autoscale_idle_timeout_minutes: float | None = 1.0)[source]#
Set up a global mode cluster. The global Ray on spark cluster means: - You can only create one active global Ray on spark cluster at a time. On databricks cluster, the global Ray cluster can be used by all users, - as contrast, non-global Ray cluster can only be used by current notebook user. - It is up persistently without automatic shutdown. - On databricks notebook, you can connect to the global cluster by calling
ray.init()without specifying its address, it will discover the global cluster automatically if it is up.For global mode, the
ray_temp_root_dirargument is not supported. Global model Ray cluster always use the default Ray temporary directory path.All arguments are the same with
setup_ray_clusterAPI except that: - theray_temp_root_dirargument is not supported. Global model Ray cluster always use the default Ray temporary directory path. - A new argument “is_blocking” (defaultTrue) is added. If “is_blocking” is True, then keep the call blocking until it is interrupted. once the call is interrupted, the global Ray on spark cluster is shut down andsetup_global_ray_clustercall terminates. If “is_blocking” is False, once Ray cluster setup completes, return immediately.- Parameters:
max_worker_nodes (int) – The maximum number of Ray worker nodes to start. Set it to
ray.util.spark.MAX_NUM_WORKER_NODESto use all available resources of the Spark application.is_blocking (bool) – If True, block until the call is interrupted, then shut down the cluster. If False, return once the cluster is set up.
min_worker_nodes (int | None) – The minimum number of worker nodes. If None or equal to
max_worker_nodes, autoscaling is disabled.num_cpus_worker_node (int | None) – The number of CPUs available to each Ray worker node. See
setup_ray_clusterfor the default.num_cpus_head_node (int | None) – The number of CPUs available to the Ray head node. Defaults to the number of CPU cores on the Spark driver node.
num_gpus_worker_node (int | None) – The number of GPUs available to each Ray worker node. See
setup_ray_clusterfor the default.num_gpus_head_node (int | None) – The number of GPUs available to the Ray head node. Defaults to the number of GPUs on the Spark driver node.
memory_worker_node (int | None) – The heap memory for each Ray worker node, passed as
--memorytoray start.memory_head_node (int | None) – The heap memory for the Ray head node, passed as
--memorytoray start.object_store_memory_worker_node (int | None) – The object store memory for each Ray worker node. See
setup_ray_clusterfor the default and cap.object_store_memory_head_node (int | None) – The object store memory for the Ray head node. See
setup_ray_clusterfor the default and cap.head_node_options (Dict | None) – Extra
ray startoptions for the head node, with keys infoo_barform and None as the value of a flag option.worker_node_options (Dict | None) – Extra
ray startoptions for the worker nodes, with keys infoo_barform and None as the value of a flag option.strict_mode (bool) – If True, raise an exception when the Spark cluster lacks the resources for the requested allocation. If False, log a warning.
collect_log_to_path (str | None) – If set, the path to collect the Ray node logs to after the nodes terminate.
autoscale_upscaling_speed (float | None) – The number of nodes allowed to be pending as a multiple of the current number of nodes, when autoscaling is enabled.
autoscale_idle_timeout_minutes (float | None) – The number of minutes a worker node must be idle before the autoscaler removes it, when autoscaling is enabled.
- Returns:
If
is_blockingis False, a tuple of(address, remote_connection_address), assetup_ray_clusterreturns. Otherwise None, once the cluster shuts down.