FlagEmbedding icon indicating copy to clipboard operation
FlagEmbedding copied to clipboard

AssertionError: daemonic processes are not allowed to have children

Open sungkim11 opened this issue 1 year ago • 7 comments

I keep on getting this AssertionError when I try to use FlagEmbedding outside of the provided sample. Can you provide an example of getting around this problem?

sungkim11 avatar Mar 21 '24 18:03 sungkim11

The code I am getting error may be here:

from FlagEmbedding import LayerWiseFlagLLMReranker reranker = LayerWiseFlagLLMReranker('BAAI/bge-reranker-v2-minicpm-layerwise', use_fp16=True)

or here:

scores = [reranker.compute_score([query, passage], cutoff_layers=cutoff_layers) for query, passage in pairs]

sungkim11 avatar Mar 21 '24 18:03 sungkim11

Loading checkpoint shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3/3 [00:04<00:00, 1.40s/it] 0%| | 0/1 [00:00<?, ?it/s] daemonic processes are not allowed to have children

sungkim11 avatar Mar 21 '24 21:03 sungkim11

Seems like you encountered errors while using multiprocessing. You could try setting multiprocessing.set_start_method('spawn') before multiprocessing.Process to address this issue.

545999961 avatar Mar 22 '24 06:03 545999961

I am calling literally sample code from fastapi code and I get this error. Any resolution since I am not using multiprocessing.

sungkim11 avatar Mar 22 '24 08:03 sungkim11

This indeed appears to be an error caused by multiprocessing. You can import multiprocessing and then try setting multiprocessing.set_start_method('spawn').

545999961 avatar Mar 22 '24 09:03 545999961

I have tried the following:

  • mulitprocessing
  • concurrent.futures
  • threading

to get around this problem. Now, I am about to try Celery to go around this problem.

sungkim11 avatar Mar 22 '24 19:03 sungkim11

Could you please provide more code? We want to analyze the code to identify the cause since the specific error location is unclear.

545999961 avatar Mar 23 '24 03:03 545999961

The code fails here with this error when called from fastapi -> daemonic processes are not allowed to have children

scores = [reranker.compute_score([query, passage], cutoff_layers=cutoff_layers) for query, passage in pairs]

sungkim11 avatar Mar 24 '24 01:03 sungkim11

ok. I found the culprit - it is hypercorn. Your code conflicts with hypercorn.

sungkim11 avatar Mar 24 '24 05:03 sungkim11

Closing this issue since it is not error with FlagEmbedding.

sungkim11 avatar Mar 25 '24 21:03 sungkim11