-
Notifications
You must be signed in to change notification settings - Fork 216
Description
Environment
- Device: realme 8 (RMX3085), Android 11, kernel 4.14.186+
- Termux: 0.118.3 (pure, no proot/chroot)
- Total RAM: ~5.51 GiB plus 8 GB swap
- Python: 3.12
- Torch: 2.9.1 (CPU variant from pytorch wheel)
- Command:
pip install kornia(triggered during OpenGait dependency setup)
Problem
OpenGait requires kornia, which depends on kornia-rs (>=0.1.9). On Termux (aarch64-linux-android), no prebuilt wheel exists, so pip builds kornia-rs from source using maturin/cargo in release mode (-C opt-level=3).
This fails during compilation of crates kornia-3d and kornia-icp (heavy use of faer linear algebra and kiddo k-d trees) with:
error: rustc interrupted by SIGSEGV, printing backtrace
...
/data/data/com.termux/files/usr/lib/libLLVM.so(_ZN4llvm21BranchProbabilityInfo9calculateERKNS_8FunctionERKNS_8LoopInfoEPKNS_17TargetLibraryInfoEPNS_13DominatorTreeEPNS_17PostDominatorTreeE+0x370)
...
signal: 11, SIGSEGV: invalid memory reference
textIncreasing rustc stack size (RUST_MIN_STACK) does not help. This is not a code bug but excessive memory pressure from LLVM optimizations on memory-constrained Android devices.
Workaround that succeeds
Set lower optimization and parallelism before pip install:
export CARGO_PROFILE_RELEASE_OPT_LEVEL=2
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16
export CARGO_BUILD_JOBS=2 # optional, further reduces peak memory
pip install korniaThis drops peak RSS to ~1GB (from likely 2-4GB+ causing crash), allowing successful build of kornia-rs-0.1.10 and kornia-0.8.2.
Full success log snippet (build time ~10 minutes):
Finished `release` profile [optimized] target(s) in 9m 57s
Successfully installed kornia_rs-0.1.10 kornia-0.8.2
Maximum resident set size: ~1.07 GiB
Request
Add a note to installation docs warning about Android/Termux and recommending the above env vars.
Consider optional dependency on kornia without rs backend, or advocate for aarch64-android wheels in kornia-rs upstream.
Thanks for the great gait recognition framework!
Permanent Avoidance in Pure Termux
To prevent this for any future kornia/kornia-rs installs:
Add to your ~/.bashrc or ~/.profile:
export CARGO_PROFILE_RELEASE_OPT_LEVEL=2
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16
export CARGO_BUILD_JOBS=2Then source ~/.bashrc. This enforces lower-memory release builds globally for Rust crates without sacrificing too much performance (opt-level=2 is still highly optimized).
If you need full opt-level=3 for a specific project later, unset them temporarily.
This issue is inherent to Termux's resource limits + heavy generic Rust code in computer vision libs—no cleaner fix until upstream provides android wheels or lighter deps.