Skip to content

[Bug] Docker部署AstrBot启动失败:NumPy因X86_V2指令集不兼容触发RuntimeError #4169

Closed

Description

@Echo-RT

What happened / 发生了什么

通过Docker部署AstrBot项目时启动失败,核心报错为NumPy编译时依赖的X86_V2指令集在当前运行环境(Docker容器/宿主机)中不被支持,导致NumPy核心模块无法加载,进而中断项目模块导入流程,最终容器启动失败并退出。

完整错误Traceback:
[15:38:25] [Core] [DBUG] [platform.register:51]: 平台适配器 aiocqhttp 已注册
Traceback (most recent call last):
File "/AstrBot/main.py", line 10, in
from astrbot.core.initial_loader import InitialLoader
File "/AstrBot/astrbot/core/initial_loader.py", line 12, in
from astrbot.core.core_lifecycle import AstrBotCoreLifecycle
File "/AstrBot/astrbot/core/core_lifecycle.py", line 19, in
from astrbot.api import logger, sp
File "/AstrBot/astrbot/api/init.py", line 6, in
from astrbot.core.star.register import register_agent as agent
File "/AstrBot/astrbot/core/star/init.py", line 3, in
from astrbot.core.star.star_tools import StarTools
File "/AstrBot/astrbot/core/star/star_tools.py", line 37, in
from astrbot.core.star.context import Context
File "/AstrBot/astrbot/core/star/context.py", line 16, in
from astrbot.core.knowledge_base.kb_mgr import KnowledgeBaseManager
File "/AstrBot/astrbot/core/knowledge_base/kb_mgr.py", line 9, in
from .kb_db_sqlite import KBSQLiteDatabase
File "/AstrBot/astrbot/core/knowledge_base/kb_db_sqlite.py", line 9, in
from astrbot.core.db.vec_db.faiss_impl import FaissVecDB
File "/AstrBot/astrbot/core/db/vec_db/faiss_impl/init.py", line 1, in
from .vec_db import FaissVecDB
File "/AstrBot/astrbot/core/db/vec_db/faiss_impl/vec_db.py", line 4, in
import numpy as np
File "/usr/local/lib/python3.11/site-packages/numpy/init.py", line 112, in
from numpy.config import show_config
File "/usr/local/lib/python3.11/site-packages/numpy/config.py", line 4, in
from numpy._core._multiarray_umath import (
File "/usr/local/lib/python3.11/site-packages/numpy/_core/init.py", line 22, in
from . import multiarray
File "/usr/local/lib/python3.11/site-packages/numpy/_core/multiarray.py", line 11, in
from . import _multiarray_umath, overrides
RuntimeError: NumPy was built with baseline optimizations:
(X86_V2) but your machine doesn't support:
(X86_V2).

Reproduce / 如何复现?

  1. 在CPU不支持X86_V2指令集的环境中部署AstrBot项目
  2. 执行项目启动命令(如运行python /AstrBot/main.py)
  3. 观察到启动失败并抛出上述RuntimeError

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

  • 部署方式:Docker
  • Docker版本:(补充docker -v输出,示例:Docker version 24.0.7, build afdd53b)
  • AstrBot镜像基础环境:Python 3.11(从报错路径/usr/local/lib/python3.11/site-packages/numpy确认)
  • 宿主机系统:Linux(如CentOS 7/Debian 10/Ubuntu 20.04)
  • 宿主机CPU架构:x86_64(无X86_V2指令集支持)

OS

Linux

Logs / 报错日志

[15:38:25] [Core] [DBUG] [platform.register:51]: 平台适配器 aiocqhttp 已注册
Traceback (most recent call last):
File "/AstrBot/main.py", line 10, in
from astrbot.core.initial_loader import InitialLoader
File "/AstrBot/astrbot/core/initial_loader.py", line 12, in
from astrbot.core.core_lifecycle import AstrBotCoreLifecycle
File "/AstrBot/astrbot/core/core_lifecycle.py", line 19, in
from astrbot.api import logger, sp
File "/AstrBot/astrbot/api/init.py", line 6, in
from astrbot.core.star.register import register_agent as agent
File "/AstrBot/astrbot/core/star/init.py", line 3, in
from astrbot.core.star.star_tools import StarTools
File "/AstrBot/astrbot/core/star/star_tools.py", line 37, in
from astrbot.core.star.context import Context
File "/AstrBot/astrbot/core/star/context.py", line 16, in
from astrbot.core.knowledge_base.kb_mgr import KnowledgeBaseManager
File "/AstrBot/astrbot/core/knowledge_base/kb_mgr.py", line 9, in
from .kb_db_sqlite import KBSQLiteDatabase
File "/AstrBot/astrbot/core/knowledge_base/kb_db_sqlite.py", line 9, in
from astrbot.core.db.vec_db.faiss_impl import FaissVecDB
File "/AstrBot/astrbot/core/db/vec_db/faiss_impl/init.py", line 1, in
from .vec_db import FaissVecDB
File "/AstrBot/astrbot/core/db/vec_db/faiss_impl/vec_db.py", line 4, in
import numpy as np
File "/usr/local/lib/python3.11/site-packages/numpy/init.py", line 112, in
from numpy.config import show_config
File "/usr/local/lib/python3.11/site-packages/numpy/config.py", line 4, in
from numpy._core._multiarray_umath import (
File "/usr/local/lib/python3.11/site-packages/numpy/_core/init.py", line 22, in
from . import multiarray
File "/usr/local/lib/python3.11/site-packages/numpy/_core/multiarray.py", line 11, in
from . import _multiarray_umath, overrides
RuntimeError: NumPy was built with baseline optimizations:
(X86_V2) but your machine doesn't support:
(X86_V2).

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • Yes!

Code of Conduct

Activity

  1. Soulter commented on Jan 18, 2026

    @Soulter
    Member

    AstrBot 需要 numpy 依赖,可以考虑更换机器.. X86_V2 指令集已经相当普及了,除非你用的是很旧的 CPU

  2. oolongcha024 commented on Mar 5, 2026

    @oolongcha024

    同样遇到该问题,这里分享一下 Ubuntu 上手动编译无任何编译器优化版本的 Numpy 过程。

    环境信息

    • NumPy 版本:2.4.0
    • 操作系统:Ubuntu Server 24.04

    步骤 1:安装编译依赖

    sudo apt build-dep numpy

    步骤 2:克隆仓库并切换到目标版本

    git clone https://github.com/numpy/numpy.git && cd numpy
    git checkout v2.4.0

    步骤 3:编译(禁用所有指令集优化)

    通过 -Dcpu-baseline="none" 和 -Dcpu-dispatch="none" 参数,确保编译产物不依赖任何特定指令集:

    python -m build --wheel \
        -Csetup-args=-Dcpu-baseline="none" -Csetup-args=-Dcpu-dispatch="none"

    步骤 4:安装编译产物

    编译完成后,wheel 文件位于 dist/ 目录下,使用 --force-reinstall 覆盖原有安装:

    pip install /path/to/numpy/dist/numpy-2.4.0-cp312-cp312-linux_x86_64.whl --force-reinstall

    至此,问题解决。

    Warning

    通过这种方式安装 Numpy 以后,一定要使用 uv run --no-sync 运行项目。

  3. oolongcha024 commented on Mar 5, 2026

    @oolongcha024

    另外补充一些内容,部分云服务器可能采用了虚拟化技术,而虚拟化平台默认给虚拟机分配的虚拟 CPU 很可能故意隐藏宿主机的新指令集,只暴露一个最保守的指令集组合。

    参见:虚拟机 CPU 指令集问题排查:glibc 报错 CPU does not support x86-64-v2

  4. Sjshi763 commented on Mar 6, 2026

    @Sjshi763
    Contributor

    sudo apt build-dep

    高手!
    @Soulter 这个可以转移到讨论区

  5. self-assigned this
    on Oct 15, 2026
  6. locked and limited conversation to collaborators on Oct 15, 2026
  7. converted this issue into a discussion #10569 on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions