{"id":22478,"library":"treelite-runtime","title":"Treelite Runtime","description":"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.","status":"active","version":"3.9.1","language":"python","source_language":"en","source_url":"https://github.com/dmlc/treelite","tags":["tree-based models","inference","runtime","compiled models"],"install":[{"cmd":"pip install treelite-runtime","lang":"bash","label":"Install treelite-runtime"}],"dependencies":[],"imports":[{"note":"Common mistake: treelite-runtime is a separate package. Import from treelite_runtime, not treelite.","wrong":"from treelite import TreeliteRuntimeError","symbol":"TreeliteRuntimeError","correct":"from treelite_runtime import TreeliteRuntimeError"},{"note":"Main class for loading compiled models.","symbol":"Predictor","correct":"from treelite_runtime import Predictor"}],"quickstart":{"code":"from treelite_runtime import Predictor\n# Load a compiled model (e.g., mymodel.so)\n# predictor = Predictor('./mymodel.so', nthread=1)\n# result = predictor.predict(batch)\nprint('Predictor loaded successfully')\n# Note: Requires a compiled .so file generated by treelite","lang":"python","description":"Basic usage of treelite-runtime to load a compiled model and run inference."},"warnings":[{"fix":"Use matching versions: treelite==3.9.1 and treelite-runtime==3.9.1, or upgrade both to 4.x when treelite-runtime updates.","message":"The treelite-runtime package version (3.9.1) is older than the latest treelite compiler (4.x). Ensure compatibility between compiler and runtime versions.","severity":"gotcha","affected_versions":">=4.0.0 compiler with <4.0.0 runtime"},{"fix":"Compile the model first using treelite compiler, then pass the file path to Predictor.","message":"Predictor expects a compiled model file (e.g., .so, .dll), not a Treelite model object. Trying to pass a treelite.Model object directly raises TypeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Create separate Predictor instances per thread, or use locks.","message":"The Predictor class is not thread-safe. Calling predict concurrently may cause data races.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: pip install treelite-runtime","cause":"The package 'treelite-runtime' is not installed.","error":"ModuleNotFoundError: No module named 'treelite_runtime'"},{"fix":"Ensure the .so file exists and path is correct. Generate with treelite compiler: treelite.Model.export_lib(target='mymodel.so', ...)","cause":"The compiled model file path is incorrect or not generated.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'mymodel.so'"},{"fix":"Check platform compatibility (e.g., compile for same architecture). Use ldd mymodel.so to verify dependencies.","cause":"The shared library is missing dependencies or architecture mismatch.","error":"OSError: /path/to/mymodel.so: cannot open shared object file"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}