Why does the Ray returns the FUNCTION_SIZE_ERROR_THRESHOLD?

Viewed 173

I just started to use Ray for handling the data.

I tried to install the code below,

import ray
ray.init(num_cpus = 16, ignore_reinit_error=True, object_store_memory = 10**10)

@ray.remote
def PROB_SCORES(words):
    encoded_tweet = tokenizer(words, return_tensors = 'pt')
    output = model(**encoded_tweet)

    # convert the tensor in probability
    scores = output[0][0].detach().numpy()
    scores = softmax(scores)

    prob_scores = scores[0] * (-1) + scores[-1] * 1 # neg to -1, pos to 1

    return prob_scores

ray.get([PROB_SCORES.remote(Tweets['Content'])]) # 'Tweets' is the dataframe which contains data.

However, I get the error message like this,

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
c:\Users\HERO\OneDrive\Github\[i-MAES]\[TextAnalysis]\TextAnalysis\NLTK_STUDY\2. Senti.ipynb Cell 11' in <cell line: 1>()
----> 1 ray.get([PROB_SCORES.remote(S8['Content'])])

File c:\Users\HERO\anaconda3\envs\text\lib\site-packages\ray\remote_function.py:111, in RemoteFunction.__init__.<locals>._remote_proxy(*args, **kwargs)
    109 @wraps(function)
    110 def _remote_proxy(*args, **kwargs):
--> 111     return self._remote(args=args, kwargs=kwargs, **self._default_options)

File c:\Users\HERO\anaconda3\envs\text\lib\site-packages\ray\util\tracing\tracing_helper.py:303, in _tracing_task_invocation.<locals>._invocation_remote_span(self, args, kwargs, *_args, **_kwargs)
    301     if kwargs is not None:
    302         assert "_ray_trace_ctx" not in kwargs
--> 303     return method(self, args, kwargs, *_args, **_kwargs)
    305 assert "_ray_trace_ctx" not in kwargs
    307 tracer = _opentelemetry.trace.get_tracer(__name__)

File c:\Users\HERO\anaconda3\envs\text\lib\site-packages\ray\remote_function.py:213, in RemoteFunction._remote(self, args, kwargs, **task_options)
    210         raise TypeError(msg) from e
    212     self._last_export_session_and_job = worker.current_session_and_job
--> 213     worker.function_actor_manager.export(self)
    215 kwargs = {} if kwargs is None else kwargs
    216 args = [] if args is None else args

File c:\Users\HERO\anaconda3\envs\text\lib\site-packages\ray\_private\function_manager.py:205, in FunctionActorManager.export(self, remote_function)
...
    653         ray_constants.FUNCTION_SIZE_ERROR_THRESHOLD // (1024 * 1024),
    654     )
--> 655     raise ValueError(error)

ValueError: The remote function __main__.PROB_SCORES is too large (476 MiB > FUNCTION_SIZE_ERROR_THRESHOLD=95 MiB). Check that its definition is not implicitly capturing a large array or other object in scope. Tip: use ray.put() to put large objects in the Ray object store.

I have no idea why this problem is happening. The 'Tweets' dataframe consumes the memory of only about 5MB.

Any help would be my lifesaver.

0 Answers
Related