Open ratnopamc opened 9 months ago
I was able to fix this issue by modifying my inference script. Please let me know/comment if you're open to accept PRs. I'm happy to create a PR to add an example of running on aws neuron with rayserve.
I face the same issue when I use the example provided by this document.
https://docs.ray.io/en/latest/cluster/kubernetes/examples/stable-diffusion-rayservice.html error log
ERROR 2024-03-12 02:02:07,778 stable_diffusion_APIIngress yjYoZj 5780f284-bcaa-4d0e-93b4-7a7856ab7428 /imagine replica.py:756 - Request failed due to RayTaskError:
Traceback (most recent call last):
File "/home/ray/anaconda3/lib/python3.8/site-packages/ray/serve/_private/replica.py", line 753, in wrap_user_method_call
yield
File "/home/ray/anaconda3/lib/python3.8/site-packages/ray/serve/_private/replica.py", line 914, in call_user_method
raise e from None
ray.exceptions.RayTaskError: ray::ServeReplica:stable_diffusion:APIIngress() (pid=235, ip=10.244.32.103)
File "/home/ray/anaconda3/lib/python3.8/site-packages/ray/serve/_private/utils.py", line 165, in wrap_to_ray_error
raise exception
File "/home/ray/anaconda3/lib/python3.8/site-packages/ray/serve/_private/replica.py", line 895, in call_user_method
result = await method_to_call(*request_args, **request_kwargs)
File "/home/ray/anaconda3/lib/python3.8/site-packages/ray/serve/_private/http_util.py", line 408, in __call__
await self._asgi_app(
File "/home/ray/anaconda3/lib/python3.8/site-packages/fastapi/applications.py", line 1115, in __call__
await super().__call__(scope, receive, send)
File "/home/ray/anaconda3/lib/python3.8/site-packages/starlette/applications.py", line 122, in __call__
await self.middleware_stack(scope, receive, send)
File "/home/ray/anaconda3/lib/python3.8/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/home/ray/anaconda3/lib/python3.8/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/home/ray/anaconda3/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/home/ray/anaconda3/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/home/ray/anaconda3/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
raise e
File "/home/ray/anaconda3/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
await self.app(scope, receive, send)
File "/home/ray/anaconda3/lib/python3.8/site-packages/starlette/routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "/home/ray/anaconda3/lib/python3.8/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/home/ray/anaconda3/lib/python3.8/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/home/ray/anaconda3/lib/python3.8/site-packages/fastapi/routing.py", line 274, in app
raw_response = await run_endpoint_function(
File "/home/ray/anaconda3/lib/python3.8/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
return await dependant.call(**values)
File "/tmp/ray/session_2024-03-12_01-41-17_429681_8/runtime_resources/working_dir_files/https_github_com_ray-project_serve_config_examples_archive_d6acf9b99ef076a1848f506670e1290a11654ec2/stable_diffusion/stable_diffusion.py", line 27, in generate
image = await image_ref
TypeError: object Image can't be used in 'await' expression
INFO 2024-03-12 02:02:07,779 stable_diffusion_APIIngress yjYoZj 5780f284-bcaa-4d0e-93b4-7a7856ab7428 /imagine replica.py:772 - __CALL__ ERROR 50383.7ms
@ratnopamc could you share how did you fixed it?
I think example code somehow let the ActorRef
to be awaited twice, which leads to the runtime error you see. One await dereferenced the ActorRef (aka. future).
image_ref = await self.handle.generate.remote(prompt)
image = await image_ref
The existing doc has fixed this problem by using
image = await self.handle.generate.remote(prompt)
I'm using the Stable Diffusion Configuration and modified it in order to run on an inferentia2 instance. My inference script is as below
When I send a request to the endpoint like
http://127.0.0.1:8000/imagine?prompt={input}
I get the below error