Files
ssw-mpc/docs/RAY_ARMV7.md
T
rong d60fcf40ca fix(docs): Ray 在 armv7 上确实能跑——更正错误结论并附实测
用户指出社区编过 ray 1.0.1 armv7l wheel。核实为真,之前的"不可能"是错的。

PyPI 侧仍是事实:135 个版本 5087 个 wheel,armv7l/armhf/armv6 共 0 个,
piwheels 全 skip(binary only),无 sdist。但社区有人编:
- PidgeyBE 1.0.1 (cp36)、PeterPirog 1.2.0 (cp38),issue #12128
- 唯一需要的改动是 setup.py 加 --linkopt=-latomic(8 字节原子要 libatomic)

实物核对(ray-1.0.1-cp36-cp36m-linux_armv7l.whl,19MB→64MB):
_raylet.so 16.4MB / raylet 13.1MB / gcs_server 10.9MB,
全部 ELF32 ARM EABI5 hard-float;_raylet.so 导出 2040 个 ray:: 符号,
CoreWorkerProcess::Initialize/GetCoreWorker/RunTaskExecutionLoop 齐全,
无 B5cxx11(同样是旧 ABI),所以 shim 那套做法在 armv7 也成立。

实测跑通完整节点(x86_64 沙箱 + qemu-arm-static 真 ELF32 执行):
redis(带 ray 模块) → gcs_server:6392 → plasma → raylet:6393,
NodeManager ID ebb89cb9…,GCS 回 IsAlive = 1。

顺带记三个非 32 位坑:redis 要手工播种 5 个键;容器 /dev/shm 64MB 要改
plasma 目录;raylet 硬性要求一个 worker_command。

代价也说清:1.0.1 是 2020-12 代码,GCS 协议与 2.x 不同,接不进现代集群;
cp36 要 python3.6;44.6MB 二进制。默认仍走 nax-orch。

新增 docs/RAY_ARMV7.md + ray/armv7/{run_node,run_gcs_only}.sh;
RAY_CORE.md §5 与状态表改正。
2026-10-30 12:07:19 +08:00

6.3 KiB
Raw Blame History

Ray 1.0.1 在 armv7 上实测记录

结论先说:Ray 在 armv7 上是能跑的,而且我们跑通了完整节点。 之前 docs/RAY_CORE.md §5 写的「Zynq 上不通」是错的,已改。

1. 包从哪来

PyPI 上确实没有,但社区编过:

来源 版本 Python 链接
PidgeyBE 1.0.1 cp36 github.com/ray-project/ray/files/5703429/ray_armv7l_32bit.zip
PeterPirog 1.2.0 cp38 github.com/PeterPirog/Raspberry_armv7_builds/tree/main/ray

上游 issue:ray-project/ray#12128。 1.2.0 之后没人再编,官方 2.0.0.dev 在 armv7 上就失败了。

唯一需要的源码改动是链接参数(PeterPirog 在讨论区的原话):

# python/setup.py,给 bazel build 加一个 linkopt
["build", "--linkopt=-latomic", "--"] + bazel_targets

原因是 32 位 ARM 上 std::atomic<int64_t> 会落成 __atomic_load_8 / __atomic_fetch_add_8,libgcc 里没有内联版本,必须显式链 libatomic。 这不是移植工程,是加一个编译/链接宏。

2. 实物核对(2026-10-30 实测)

ray-1.0.1-cp36-cp36m-linux_armv7l.whl:19 MB 压缩、64 MB 解压。

组件 大小 架构
_raylet.so 16.4 MB ELF32 ARM,flags 0x5000400(EABI5 + hard-float)
raylet 13.1 MB 同上
gcs_server 10.9 MB 同上
libray_redis_module.so 3.6 MB 同上
redis-server 3.4 MB 同上
plasma_store_server 0.8 MB 同上

C++ 侧合计约 44.6 MB(对照 x86_64 的 2.59:_raylet.so 44 MB + raylet 35 MB + gcs 40 MB)。

_raylet.so 的动态符号:10562 条,其中 ray:: 命名空间 2040 个,且 CoreWorkerProcess 全套导出:

T _ZN3ray17CoreWorkerProcess10InitializeERKNS_17CoreWorkerOptionsE@@VERSION_1.0
T _ZN3ray17CoreWorkerProcess13GetCoreWorkerEv@@VERSION_1.0
T _ZN3ray17CoreWorkerProcess20RunTaskExecutionLoopEv@@VERSION_1.0
T _ZN3ray17CoreWorkerProcess8ShutdownEv@@VERSION_1.0

符号名里没有 B5cxx11 —— 和 2.59 一样是旧 ABI(_GLIBCXX_USE_CXX11_ABI=0)。 也就是说 ray/nax_ray_shim.cc 那套「绕开 bazel、直接链 _raylet.so」的做法 在 armv7 上同样成立,只是 API 要从 2.59 回退到 1.0.1。

3. 完整节点跑通

环境:x86_64 沙箱 + qemu-arm-static -L /usr/lib/arm-linux-gnueabihf (qemu 只做用户态指令翻译,不是模拟编译,跑的是真 ELF32 ARM 二进制)。

手工做掉 ray start --head 的 bootstrap(因为板上没有 python3.6), ray/armv7/run_node.sh 完整复现:

  1. 主 redis :6390 + 分片 redis :6391,都 --loadmodule libray_redis_module.so
  2. 播种 5 个键(等同 services.py::start_redis): NumRedisShards=1、RedirectOutput=0、JobCounter=0、ray_version、RedisShards
  3. gcs_server :6392
  4. plasma_store_server(注意容器 /dev/shm 只有 64 MB,要 -d /tmp/plasmadir -m 50M)
  5. raylet --node_manager_port=6393

实测输出:

Module 'ray' loaded from .../libray_redis_module.so
GcsServer server started, listening on port 6392
Gcs server address = 127.0.0.1:6392
ObjectManager server started, listening on port 34591
node_manager.cc:178] Initializing NodeManager with ID ebb89cb915e55e838bcadeb10b7bcb16b9cfb643
NodeManager server started, listening on port 6393
service_based_accessor.cc:775] Received notification for node id = ebb89cb9…, IsAlive = 1
raylet 存活 ✅

IsAlive = 1 是 GCS 收到 raylet 注册后的确认。整条链 redis(带 ray 模块)→ gcs_server → plasma → raylet 在 armv7 上都成立。

两个不是 32 位问题的坑

现象 真因 处理
Check failed: No entry found for NumRedisShards redis 没被 bootstrap 播种 手工写 5 个键
System memory request exceeds memory available in /dev/shm 容器 /dev/shm 只有 64 MB -d /tmp/plasmadir -m 50M
At least one of Python/Java/CPP worker command should be provided raylet 硬性校验 --num_initial_workers=0 时给 --cpp_worker_command=/bin/true

4. 但这条路对 nax 的代价(必须说清)

能跑 ≠ 该用。三个真实代价:

  1. 版本断层。1.0.1 是 2020-12 的代码,GCS 协议和 2.59 不同,接不进现代 Ray 集群。 要么整集群降级到 1.x,要么边缘独立成一个小集群。
  2. 要 python3.6。wheel 是 cp36,_raylet.so 是 CPython 扩展(和 2.59 同样有几百个 Py* 未定义符号)。板上跑得装 python3.6,或者像 crates/nax-ray/build.rs 那样链 libpython 兜住符号——但 Debian 12 / PetaLinux 都不带 3.6。
  3. 44.6 MB 二进制 + plasma 内存。ACZ7015 是 1 GB DDR3,放得下;512 MB 的板子就悬。

5. 三个选项的取舍

方案 工作量 能得到 风险
A. 用 1.0.1 armv7 + 移植 shim 中(改 ~250 行 shim 到 1.0 API,交叉编译 shim) 边缘板上真的跑 Ray,能加入 1.x 集群 2020 年代码;要 python3.6
B. 自己编 2.59 armv7 大(bazel crosstool + 38 依赖全过一遍 + 未知 32 位问题) 与现代 Ray 协议一致 未知量大,可能卡死在某个依赖
C. 保持 nax-orch 零(已完成,661 行) 放置 + 成员,任意架构 没有 Ray 生态

当前选择:C 作为默认,A 作为「确实需要 Ray 生态」时的备选。 B 不建议——为一个我们只用「放置」的能力去背 38 个依赖的 32 位交叉编译。

6. 复现

# 拿包(GitHub 直连,注意 zip 可能被代理截断,用 -C - 续传)
curl -sSL --http1.1 -C - -o ray_armv7.zip \
  https://github.com/ray-project/ray/files/5703429/ray_armv7l_32bit.zip

# 环境:Debian 12 x86_64 容器
apt-get install -y qemu-user-static redis-tools
dpkg --add-architecture armhf
echo 'deb [arch=armhf] http://mirrors.ustc.edu.cn/debian bookworm main' >> /etc/apt/sources.list
apt-get update && apt-get install -y libc6:armhf libstdc++6:armhf libgcc-s1:armhf

# 解包 + 起节点
python3 -c "import zipfile;zipfile.ZipFile('ray_armv7.zip').extractall('.')"
python3 -c "import zipfile,glob;zipfile.ZipFile(glob.glob('*.whl')[0]).extractall('/tmp/r17')"
bash ray/armv7/run_node.sh      # 完整节点
bash ray/armv7/run_gcs_only.sh  # 只起控制面