Failed to register worker to Raylet

  • High: It blocks me to complete my task.

I am trying to run ray serve in a docker container on Apple Silicon M1. The image was built from bazel via pip installing ray[serve]==2.34.0. When I exec into the container, I ran python serve.py to start a simple server:

# serve.py
import subprocess
from typing import Any

import ray
from ray import serve
from starlette.requests import Request

subprocess.run(["ray", "start", "--head"])

ray.init()
serve.start(detached=True, http_options={"host": "0.0.0.0"})


@serve.deployment
class Hello:
    def __init__(self):
        pass

    async def __call__(self, starlette_request: Request) -> dict[str, Any]:
        req = await starlette_request.json()
        name = req["name"]
        return {"response": f"Hello {name}!"}


serve.run(Hello.bind(), blocking=True)

But I got an error:

2024-08-14 05:18:37,439	INFO worker.py:1596 -- Connecting to existing Ray cluster at address: 172.26.0.2:6379...
2024-08-14 05:18:37,535	INFO worker.py:1772 -- Connected to Ray cluster. View the dashboard at http://127.0.0.1:8265 
[2024-08-14 05:18:37,834 E 30 30] core_worker.cc:251: Failed to register worker 01000000ffffffffffffffffffffffffffffffffffffffffffffffff to Raylet. IOError: [RayletClient] Unable to register worker with raylet. No such file or directory

Does my serve.py look correct? Any tips on how to get around this issue? Thanks!

I figured it out myself. It turns out to be an architecture issue. After building the image that is compatible to the ARM architecture, it is working as intended:

app-1  | 2024-08-14 17:50:45,233	INFO worker.py:1596 -- Connecting to existing Ray cluster at address: 172.26.0.2:6379...
app-1  | 2024-08-14 17:50:45,238	INFO worker.py:1772 -- Connected to Ray cluster. View the dashboard at http://172.26.0.2:8265 
...
app-1  | 2024-08-14 17:50:47,805	INFO handle.py:126 -- Created DeploymentHandle '519ducf9' for Deployment(name='Hello', app='default').
app-1  | 2024-08-14 17:50:47,805	INFO api.py:574 -- Deployed app 'default' successfully.