Registry / ai-ml / treelite-runtime

treelite-runtime

JSON →
library3.9.1pypypi✓ verified 86d ago

Treelite runtime is the lightweight inference engine for tree models compiled by Treelite. It loads compiled shared libraries (.so/.dll) and runs predictions. Current version on PyPI is 3.9.1 (note: GitHub releases have advanced to 4.x, but treelite-runtime may lag). Released monthly.

pip install treelite-runtime
INSTALL
IMPORT
SIG · TREELITE-RUNTIME
T
treelite-runtime
ai-mlpythonv3.9.1
Install
7.3s avg
Import
904ms
Disk
226MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.95 runs
build_error
glibc
py 3.103.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.
fix
Use 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.
fix
Compile 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.
fix
Create 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.
fix
Run: pip install treelite-runtime
FileNotFoundError: [Errno 2] No such file or directory: 'mymodel.so'
The compiled model file path is incorrect or not generated.
fix
Ensure 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.
fix
Check 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.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
treelite-runtime — pip install treelite-runtime · libregistry