diff --git a/python/ray/serve/api.py b/python/ray/serve/api.py index 0478fa935..9f6232372 100644 --- a/python/ray/serve/api.py +++ b/python/ray/serve/api.py @@ -651,7 +651,6 @@ def start( http_port: int = DEFAULT_HTTP_PORT, http_middlewares: List[Any] = [], http_options: Optional[Union[dict, HTTPOptions]] = None, - dedicated_cpu: bool = False, ) -> Client: """Initialize a serve instance. @@ -676,7 +675,7 @@ def start( this to "0.0.0.0". - port(int): Port for HTTP server. Defaults to 8000. - middlewares(list): A list of Starlette middlewares that will be - applied to the HTTP servers in the cluster. Defaults to []. + applied to the HTTP servers in the cluster. - location(str, serve.config.DeploymentMode): The deployment location of HTTP servers: @@ -685,10 +684,6 @@ def start( on. This is the default. - "EveryNode": start one HTTP server per node. - "NoServer" or None: disable HTTP server. - - num_cpus (int): The number of CPU cores to reserve for each - internal Serve HTTP proxy actor. Defaults to 0. - dedicated_cpu (bool): Whether to reserve a CPU core for the internal - Serve controller actor. Defaults to False. """ if ((http_host != DEFAULT_HTTP_HOST) or (http_port != DEFAULT_HTTP_PORT) or (len(http_middlewares) != 0)): @@ -733,7 +728,6 @@ def start( host=http_host, port=http_port, middlewares=http_middlewares) controller = ServeController.options( - num_cpus=(1 if dedicated_cpu else 0), name=controller_name, lifetime="detached" if detached else None, max_restarts=-1, diff --git a/python/ray/serve/config.py b/python/ray/serve/config.py index ce36ac7df..d14375083 100644 --- a/python/ray/serve/config.py +++ b/python/ray/serve/config.py @@ -244,7 +244,6 @@ class HTTPOptions(pydantic.BaseModel): port: int = DEFAULT_HTTP_PORT middlewares: List[Any] = [] location: Optional[DeploymentMode] = DeploymentMode.HeadOnly - num_cpus: int = 0 @validator("location", always=True) def location_backfill_no_server(cls, v, values): diff --git a/python/ray/serve/controller.py b/python/ray/serve/controller.py index e55cd153f..b7a80cf1e 100644 --- a/python/ray/serve/controller.py +++ b/python/ray/serve/controller.py @@ -38,7 +38,7 @@ CHECKPOINT_KEY = "serve-controller-checkpoint" CONTROL_LOOP_PERIOD_S = 0.1 -@ray.remote(num_cpus=0) +@ray.remote class ServeController: """Responsible for managing the state of the serving system. diff --git a/python/ray/serve/examples/doc/quickstart_class.py b/python/ray/serve/examples/doc/quickstart_class.py index f651fa947..886a0763e 100644 --- a/python/ray/serve/examples/doc/quickstart_class.py +++ b/python/ray/serve/examples/doc/quickstart_class.py @@ -2,7 +2,7 @@ import ray from ray import serve import requests -ray.init() +ray.init(num_cpus=4) serve.start() diff --git a/python/ray/serve/examples/doc/quickstart_function.py b/python/ray/serve/examples/doc/quickstart_function.py index 011dd0d31..91f6934de 100644 --- a/python/ray/serve/examples/doc/quickstart_function.py +++ b/python/ray/serve/examples/doc/quickstart_function.py @@ -2,7 +2,7 @@ import ray from ray import serve import requests -ray.init() +ray.init(num_cpus=4) serve.start() diff --git a/python/ray/serve/http_proxy.py b/python/ray/serve/http_proxy.py index 97fa1555c..af996b9fa 100644 --- a/python/ray/serve/http_proxy.py +++ b/python/ray/serve/http_proxy.py @@ -164,7 +164,7 @@ class HTTPProxy: await self.router(scope, receive, send) -@ray.remote(num_cpus=0) +@ray.remote class HTTPProxyActor: def __init__(self, host: str, diff --git a/python/ray/serve/http_state.py b/python/ray/serve/http_state.py index 096016379..ecf4c6783 100644 --- a/python/ray/serve/http_state.py +++ b/python/ray/serve/http_state.py @@ -69,7 +69,6 @@ class HTTPState: name, node_id, self._config.host, self._config.port)) proxy = HTTPProxyActor.options( - num_cpus=self._config.num_cpus, name=name, lifetime="detached" if self._detached else None, max_concurrency=ASYNC_CONCURRENCY, diff --git a/python/ray/serve/tests/test_standalone.py b/python/ray/serve/tests/test_standalone.py index 5c2e40967..5ca5529b5 100644 --- a/python/ray/serve/tests/test_standalone.py +++ b/python/ray/serve/tests/test_standalone.py @@ -15,7 +15,6 @@ from ray.serve.constants import SERVE_PROXY_NAME from ray.serve.exceptions import RayServeException from ray.serve.utils import (block_until_http_ready, get_all_node_ids, format_actor_name) -from ray.serve.config import HTTPOptions from ray.test_utils import wait_for_condition from ray._private.services import new_port @@ -122,30 +121,6 @@ def test_connect(detached, ray_shutdown): assert "backend-ception" in serve.list_backends().keys() -@pytest.mark.skipif(sys.platform == "win32", reason="Failing on Windows") -@pytest.mark.parametrize("controller_cpu", [True, False]) -@pytest.mark.parametrize("num_proxy_cpus", [0, 1, 2]) -def test_dedicated_cpu(controller_cpu, num_proxy_cpus, ray_cluster): - cluster = ray_cluster - num_cluster_cpus = 8 - head_node = cluster.add_node(num_cpus=num_cluster_cpus) - - ray.init(head_node.address) - wait_for_condition( - lambda: ray.cluster_resources().get("CPU") == num_cluster_cpus) - - num_cpus_used = int(controller_cpu) + num_proxy_cpus - - serve.start( - dedicated_cpu=controller_cpu, - http_options=HTTPOptions(num_cpus=num_proxy_cpus)) - available_cpus = num_cluster_cpus - num_cpus_used - wait_for_condition( - lambda: (ray.available_resources().get("CPU") == available_cpus)) - serve.shutdown() - ray.shutdown() - - @pytest.mark.skipif( not hasattr(socket, "SO_REUSEPORT"), reason=("Port sharing only works on newer verion of Linux. " @@ -329,7 +304,7 @@ def test_http_head_only(ray_cluster): r["CPU"] for r in ray.state.state._available_resources_per_node().values() } - assert cpu_per_nodes == {4, 4} + assert cpu_per_nodes == {2, 4} if __name__ == "__main__":