Hi,
I’d like to use the ‘container’ option but I’m not sure how to make it work? The following code works when I run it on the command line
# tf1/main.py
import tensorflow as tf
import time
DEPLOY_TIME = time.time()
class Predictor:
def __init__(self):
print("Initializing Predictor")
pass
def work(self):
return tf.__version__ + f"|{DEPLOY_TIME}"
pass
if __name__ == "__main__":
print("Deploy Time:" + str(DEPLOY_TIME))
import ray
import os
ray.init(namespace='indexing')
try:
old = ray.get_actor("tf1")
print("Killing TF1")
ray.kill(old)
except ValueError:
print("Not Killing TF1 as it's not present")
PredictorActor = ray.remote(Predictor)
PredictorActor.options(name="tf1", lifetime="detached").remote()
a = ray.get_actor("tf1")
print("Named Actor Call")
print(ray.get(a.work.remote()))
On the command line, it works with
ray job submit --runtime-env-json='{"working_dir": "./", "pip": ["tensorflow==1.15"], "excludes": ["venv"]}' -- python main.py
Re: using a container.
I’ve tried the following code.
#Dockerfile
# set base image (host OS)
FROM python:3.6
# set the working directory in the container
WORKDIR /code
# copy the dependencies file to the working directory
COPY requirements.txt .
# install dependencies
RUN pip install -r requirements.txt
# copy the content of the local src directory to the working directory
COPY . .
# command to run on container start
CMD [ "python", "main.py" ]
I build an image as ‘tf1:latest’ and then try
ray job submit --runtime-env-json='{"container": {"image": "tf1:latest"}}' -- python main.py
My client calling code(which works when run on the command line but not when using a container)
#client
import ray
ray.init(namespace="indexing")
print("Ray Namespace")
print(ray.get_runtime_context().namespace)
print("In Pipeline Indexing Both")
a = ray.get_actor("tf1")
print(ray.get(a.work.remote()))