Description
Summary:
pip install -v lightgbm
kinda works, but then the installer compiles the package from scratch via ninja and thus causes the out of memory errors, even on a Droid with about 16 GB virtual (swap) plus real RAM, only in Termux. (It works fine in the Prooted OSes, out of the box, as nothing gets compiled there). I tried adding .toml switches to make the compiler use some -j1
like args, but I failed. The below method only works, some of the below was written by ChatGPT:
Description
One needs to install LightGBM's Python package from a precompiled lib_lightgbm.so
build using:
bash build-python.sh --precompile --no-isolation install
The script still triggers:
- a temporary isolated virtual environment
- execution of
python -m build --sdist
- multiple warnings about deprecated
project.license
syntax
The behavior is harmless, but unexpected. The invocation also indirectly uses setuptools’ isolated environment to generate the sdist even though no compilation happens. The script succeeds — but a warning-free, venv-free flow would be ideal when all build artifacts are already present.
Reproducible example
# Prepare and compile manually
cmake -S. -Bbuild-lightgbm -DCMAKE_BUILD_TYPE=Release \
-D__BUILD_FOR_PYTHON=ON -D__INTEGRATE_OPENCL=OFF -DUSE_OPENMP=OFF -G"Unix Makefiles"
make -C build-lightgbm -j1
# Then:
bash build-python.sh --precompile --no-isolation install
Environment info
LightGBM version or commit hash:
master
, commit near LightGBM v4.6.0.99
Command(s) you used to install LightGBM
bash build-python.sh --precompile --no-isolation install
Platform:
Termux on Android 11, using Clang and Make
My tweaks to CmakeList, for good measure:
~/downloads/LightGBM $ head CMakeLists.txt -n 30
option(USE_MPI "Enable MPI-based distributed learning" OFF)
option(USE_OPENMP "Enable OpenMP" ON)
option(USE_GPU "Enable GPU-accelerated training" OFF)
option(USE_SWIG "Enable SWIG to generate Java API" OFF)
option(USE_TIMETAG "Set to ON to output time costs" ON)
option(USE_CUDA "Enable CUDA-accelerated training " OFF)
option(USE_DEBUG "Set to ON for Debug mode" OFF)
option(USE_SANITIZER "Use sanitizer flags" OFF)
set(
ENABLED_SANITIZERS
"address" "leak" "undefined"
CACHE
STRING
"Semicolon separated list of sanitizer names, e.g., 'address;leak'. \
Supported sanitizers are address, leak, undefined and thread."
)
option(USE_HOMEBREW_FALLBACK "(macOS-only) also look in 'brew --prefix' for libraries (e.g. OpenMP)" ON)
option(BUILD_CLI "Build the 'lightgbm' command-line interface in addition to lib_lightgbm" ON)
option(BUILD_CPP_TEST "Build C++ tests with Google Test" OFF)
option(BUILD_STATIC_LIB "Build static library" OFF)
option(INSTALL_HEADERS "Install headers to CMAKE_INSTALL_PREFIX (e.g. '/usr/local/include')" ON)
option(__BUILD_FOR_PYTHON "Set to ON if building lib_lightgbm for use with the Python-package" ON)
option(__BUILD_FOR_R "Set to ON if building lib_lightgbm for use with the R-package" OFF)
option(__INTEGRATE_OPENCL "Set to ON if building LightGBM with the OpenCL ICD Loader and its dependencies included" OFF)
cmake_minimum_required(VERSION 3.28)
# If using Visual Studio generators, always target v10.x of the Windows SDK.
# Doing this avoids lookups that could fall back to very old versions, e.g. by finding
# outdated registry entries.
~/downloads/LightGBM $
Result:
~/downloads/LightGBM $ pip show lightgbm
Name: lightgbm
Version: 4.6.0.99
Summary: LightGBM Python-package
Home-page: https://github.com/microsoft/LightGBM
Author:
Author-email:
License: The MIT License (MIT)
under:
~/downloads/LightGBM $ uname -a
Linux localhost 4.14.186+ #1 SMP PREEMPT Thu Mar 17 16:28:22 CST 2022 aarch64 Android
~/downloads/LightGBM $
Ver. 1.3, typos removed and meaning hopefully cleared up.