Install & Compatibility
Where this runs
tested against v3.9.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
build_error
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 7.3s · import 0.904s · 222MB
226MB installed
● package 226MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
TreeliteRuntimeError
✓ from treelite_runtime import TreeliteRuntimeError
✗ from treelite import TreeliteRuntimeError
Common mistake: treelite-runtime is a separate package. Import from treelite_runtime, not treelite.
Predictor
✓ from treelite_runtime import Predictor
Main class for loading compiled models.
Basic usage of treelite-runtime to load a compiled model and run inference.
from treelite_runtime import Predictor
# Load a compiled model (e.g., mymodel.so)
# predictor = Predictor('./mymodel.so', nthread=1)
# result = predictor.predict(batch)
print('Predictor loaded successfully')
# Note: Requires a compiled .so file generated by treelite
Debug
Known issues
gotchaThe treelite-runtime package version (3.9.1) is older than the latest treelite compiler (4.x). Ensure compatibility between compiler and runtime versions.fixUse matching versions: treelite==3.9.1 and treelite-runtime==3.9.1, or upgrade both to 4.x when treelite-runtime updates.
affects: >=4.0.0 compiler with <4.0.0 runtime
gotchaPredictor expects a compiled model file (e.g., .so, .dll), not a Treelite model object. Trying to pass a treelite.Model object directly raises TypeError.fixCompile the model first using treelite compiler, then pass the file path to Predictor.
affects: all
gotchaThe Predictor class is not thread-safe. Calling predict concurrently may cause data races.fixCreate separate Predictor instances per thread, or use locks.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'treelite_runtime'
The package 'treelite-runtime' is not installed.
fixRun: pip install treelite-runtime
FileNotFoundError: [Errno 2] No such file or directory: 'mymodel.so'
The compiled model file path is incorrect or not generated.
fixEnsure the .so file exists and path is correct. Generate with treelite compiler: treelite.Model.export_lib(target='mymodel.so', ...)
OSError: /path/to/mymodel.so: cannot open shared object file
The shared library is missing dependencies or architecture mismatch.
fixCheck platform compatibility (e.g., compile for same architecture). Use ldd mymodel.so to verify dependencies.
Upgrade
Version history
3.9.1latest on PyPI · released Sep 13, 2023
Audit
Dependencies
No dependency data recorded yet.