Hello folks
Trying to run a remote task on cpu machines but get the following value error:
buffer source array is read-only
The cropped bottom traceback:
output = model.ops.gather_add(vectors, keys)
File "thinc/backends/numpy_ops.pyx", line 440, in thinc.backends.numpy_ops.NumpyOps.gather_add
File "stringsource", line 660, in View.MemoryView.memoryview_cwrapper
File "stringsource", line 350, in View.MemoryView.memoryview.__cinit__
ValueError: buffer source array is read-only
Attaching the code snippet
import ray
import spacy
@ray.remote
def my_task(model,text):
'''
'''
print(f"Processing: {text}")
doc = model(text)
return doc
if __name__ == '__main__':
ray.init()
model = spacy.load('en_core_web_lg')
model_ref = ray.put(model)
texts = ['I like you. What are you doing?','I am fine. What about you?']
ref_ids = [my_task.remote(model_ref,text) for text in texts]
while len(ref_ids):
processed, unprocessed = ray.wait(ref_ids)
ref_ids = unprocessed
if processed:
out = ray.get(processed)
print(out)
However if I run the same model on GPU machines it throws no error. There is a slight change in the code. @ray.remote(num_gpus=1)
is introduced and spacy.require_gpu()
is called before loading the model.
ray version: 2.2.0
spacy version: 3.4.4
Please help me!
Thanks