Run Ray Task on AWS Lambda

Hello,

I have a basic Ray code that consumes resources.

My aim is to deploy Python code on AWS with dockerized. When I try to use the docker image on AWS Lambda Function, It not working.

Python code which simple consume resource:
import math
import time
import ray

#ray.init(“anyscale://ray-demo-cluster”, runtime_env={“pip”: “requirements.txt”})
#ray.init(“anyscale://anyscale-demo/kd-cluster-v1”)

@ray.remote
def factorial_func(n):
return math.factorial(n)

def lambda_handler(event, context):
start = time.time()
results = [factorial_func.remote(i*40) for i in range(2000)]
ray.get(results)
finish = time.time()
print(f’Total duration:',finish-start)

lambda_handler(None, None)

Issue:


Why is this happening?

Many thanks for your time.

I’m not sure if the issue is related to Ray. Ray doesn’t use sudo permission.

Possibly the issue is related to Anyscale. Because I am using Anyscale base image when I am building a docker image.

Dockerfile:

# Use Anyscale base image
FROM anyscale/ray:2.0.0-py37

ADD demo.py .

RUN echo "Testing Ray Import..." && python -c "import ray"

CMD [ "main.lambda_handler" ]

Is it possible?

yea it’s possible. Are you using anyscale? If not, you should use the open source ray image from https://hub.docker.com/r/rayproject/ray