netease-youdao / QAnything

Question and Answer based on Anything.
https://qanything.ai
GNU Affero General Public License v3.0
11.54k stars 1.12k forks source link

[BUG] 纯Python环境安装报错<RuntimeError: context has already been set> #283

Open kkive opened 5 months ago

kkive commented 5 months ago

是否已有关于该错误的issue或讨论? | Is there an existing issue / discussion for this?

该问题是否在FAQ中有解答? | Is there an existing answer for this in FAQ?

当前行为 | Current Behavior

运行cpu启动脚本后报错 bash scripts/run_for_openai_api_with_cpu_in_Linux_or_WSL.sh

期望行为 | Expected Behavior

正常运行

运行环境 | Environment

- OS:CentOS Linux7.9
- NVIDIA Driver:Null
- CUDA:Null
- docker:Null
- docker-compose:Null
- NVIDIA GPU:Null
- NVIDIA GPU Memory:Null

QAnything日志 | QAnything logs

(qanything-python) [root@iZbp13l9zo6j30czl5u20uZ QAnything]# bash scripts/run_for_openai_api_with_cpu_in_Linux_or_WSL.sh
即将启动后端服务,启动成功后请复制[http://0.0.0.0:8777/qanything/]到浏览器进行测试。
运行qanything-server的命令是:
python3 -m qanything_kernel.qanything_server.sanic_api --host 0.0.0.0 --port 8777 --model_size 7B --use_cpu --use_openai_api --openai_api_base https://api.openai.com/v1 --openai_api_key sk-proj-BN9dzHDHUL0RRDnKAD4RT3BlbkFJPMvaOcnZ --openai_api_model_name gpt-3.5-turbo-1106 --openai_api_context_length 4096 --workers 4
LOCAL DATA PATH: /root/QAnything/QANY_DB/content
LOCAL_RERANK_REPO: netease-youdao/bce-reranker-base_v1
LOCAL_EMBED_REPO: netease-youdao/bce-embedding-base_v1
<Logger debug_logger (INFO)> <Logger qa_logger (INFO)>
onnxruntime-gpu 未安装。
100%|████████████████████████████████████████████████████████████████████| 193M/193M [00:15<00:00, 12.3MiB/s]
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
ERROR: onnxruntime_gpu-1.17.1-cp310-cp310-manylinux_2_28_x86_64.whl is not a supported wheel on this platform.
vllm 0.2.7 已经安装。
2024-04-23 23:38:03,544 - modelscope - INFO - PyTorch version 2.1.2 Found.
2024-04-23 23:38:03,545 - modelscope - INFO - Loading ast index from /root/.cache/modelscope/ast_indexer
2024-04-23 23:38:03,587 - modelscope - INFO - Loading done! Current index file version is 1.13.0, with md5 c9b291b9317260a52ac5487dc1ad1c59 and a total number of 972 components indexed
use_cpu: True
use_openai_api: True
[2024-04-23 23:38:04 +0800] [29840] [INFO]
  ┌─────────────────────────────────────────────────────────────────────────┐
  │                              Sanic v23.6.0                              │
  │                     Goin' Fast @ http://0.0.0.0:8777                    │
  ├───────────────────────┬─────────────────────────────────────────────────┤
  │                       │     mode: production, w/ 4 workers              │
  │     ▄███ █████ ██     │   server: sanic, HTTP/1.1                       │
  │    ██                 │   python: 3.10.14                               │
  │     ▀███████ ███▄     │ platform: Linux-3.10.0-1160.108.1.el7.x86_64-x8 │
  │                 ██    │           6_64-with-glibc2.17                   │
  │    ████ ████████▀     │ packages: sanic-routing==23.12.0,               │
  │                       │           sanic-ext==23.6.0                     │
  │ Build Fast. Run Fast. │                                                 │
  └───────────────────────┴─────────────────────────────────────────────────┘

[2024-04-23 23:38:04 +0800] [29840] [WARNING] Sanic is running in PRODUCTION mode. Consider using '--debug' or '--dev' while actively developing your application.
Traceback (most recent call last):
  File "/root/anaconda3/envs/qanything-python/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/root/anaconda3/envs/qanything-python/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/root/QAnything/qanything_kernel/qanything_server/sanic_api.py", line 206, in <module>
    app.run(host=args.host, port=args.port, workers=args.workers, access_log=False)
  File "/root/anaconda3/envs/qanything-python/lib/python3.10/site-packages/sanic/mixins/startup.py", line 215, in run
    serve(primary=self)  # type: ignore
  File "/root/anaconda3/envs/qanything-python/lib/python3.10/site-packages/sanic/mixins/startup.py", line 734, in serve
    cls._set_startup_method()
  File "/root/anaconda3/envs/qanything-python/lib/python3.10/site-packages/sanic/mixins/startup.py", line 711, in _set_startup_method
    set_start_method(method, force=cls.test_mode)
  File "/root/anaconda3/envs/qanything-python/lib/python3.10/multiprocessing/context.py", line 247, in set_start_method
    raise RuntimeError('context has already been set')
RuntimeError: context has already been set
屏幕截图 2024-04-23 234357

复现方法 | Steps To Reproduce

bash scripts/run_for_openai_api_with_cpu_in_Linux_or_WSL.sh

备注 | Anything else?

No response

hfwguitar commented 5 months ago

相同的错误,配置torch.multiprocessing.set_start_method也不行 image

kkive commented 5 months ago

相同的错误,配置torch.multiprocessing.set_start_method也不行 image

你的服务器cpu和内存是多少呢

hfwguitar commented 5 months ago

8C16G image

hfwguitar commented 5 months ago

相同的错误,配置torch.multiprocessing.set_start_method也不行 image

你的服务器cpu和内存是多少呢

8c16G

hfwguitar commented 5 months ago

相同的错误,配置torch.multiprocessing.set_start_method也不行 image

你的服务器cpu和内存是多少呢 你的可以了?请问怎么解决的?

kkive commented 5 months ago

相同的错误,配置torch.multiprocessing.set_start_method也不行 image

你的服务器cpu和内存是多少呢 你的可以了?请问怎么解决的?

我的还是不行,下周用在线版,配置比你低,2c 2G,哈哈哈,群里面说可能是配置低导致的,我也不知道怎么解决

hgsw commented 5 months ago

same question, but not fix