Skip to content

Crashes when n_processes > 1 #23

Description

@cphoover

I'm seeing an issue where the pipeline crashes during msgpack serialization when I set n_processes > 1.

I want to leverage all cores on my AWS c5a.2xlarge machine so I have set n_processes = number of cores.

But now my entity linking pipeline is crashing.

Below is a paste of the stacktrace:

Traceback (most recent call last):
  File "/home/ubuntu/workspace/official_benchmark_with_linking.py", line 95, in <module>
    results = process_messages(doc_batch)
  File "/home/ubuntu/workspace/official_benchmark_with_linking.py", line 65, in process_messages
    _ = [d for d in nlp.pipe(input_data,
  File "/home/ubuntu/workspace/official_benchmark_with_linking.py", line 65, in <listcomp>
    _ = [d for d in nlp.pipe(input_data,
  File "/home/ubuntu/workspace/.env/lib/python3.10/site-packages/spacy/language.py", line 1574, in pipe
    for doc in docs:
  File "/home/ubuntu/workspace/.env/lib/python3.10/site-packages/spacy/language.py", line 1657, in _multiprocessing_pipe
    self.default_error_handler(
  File "/home/ubuntu/workspace/.env/lib/python3.10/site-packages/spacy/util.py", line 1672, in raise_error
    raise e
ValueError: [E871] Error encountered in nlp.pipe with multiprocessing:

Traceback (most recent call last):
  File "/home/ubuntu/workspace/.env/lib/python3.10/site-packages/spacy/language.py", line 2273, in _apply_pipes
    byte_docs = [(doc.to_bytes(), doc._context, None) for doc in docs]
  File "/home/ubuntu/workspace/.env/lib/python3.10/site-packages/spacy/language.py", line 2273, in <listcomp>
    byte_docs = [(doc.to_bytes(), doc._context, None) for doc in docs]
  File "spacy/tokens/doc.pyx", line 1316, in spacy.tokens.doc.Doc.to_bytes
  File "spacy/tokens/doc.pyx", line 1375, in spacy.tokens.doc.Doc.to_dict
  File "/home/ubuntu/workspace/.env/lib/python3.10/site-packages/spacy/util.py", line 1312, in to_dict
    serialized[key] = getter()
  File "spacy/tokens/doc.pyx", line 1372, in spacy.tokens.doc.Doc.to_dict.lambda20
  File "/home/ubuntu/workspace/.env/lib/python3.10/site-packages/srsly/_msgpack_api.py", line 14, in msgpack_dumps
    return msgpack.dumps(data, use_bin_type=True)
  File "/home/ubuntu/workspace/.env/lib/python3.10/site-packages/srsly/msgpack/__init__.py", line 55, in packb
    return Packer(**kwargs).pack(o)
  File "srsly/msgpack/_packer.pyx", line 285, in srsly.msgpack._packer.Packer.pack
  File "srsly/msgpack/_packer.pyx", line 291, in srsly.msgpack._packer.Packer.pack
  File "srsly/msgpack/_packer.pyx", line 288, in srsly.msgpack._packer.Packer.pack
  File "srsly/msgpack/_packer.pyx", line 264, in srsly.msgpack._packer.Packer._pack
  File "srsly/msgpack/_packer.pyx", line 282, in srsly.msgpack._packer.Packer._pack
TypeError: can not serialize 'EntityCollection' object

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions