{"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,"search_vec":"'3.9.1':30 '4':37 'advanc':35 'base':49 'compil':13,18,53 'current':25 'engin':9 'github':32 'infer':8,51 'lag':44 'librari':20 'lightweight':7 'load':17 'may':43 'model':12,50,54 'month':46 'note':31 'predict':24 'pypi':28 'releas':33,45 'run':23 'runtim':2,4,42,52 'share':19 'so/.dll':21 'tree':11,48 'tree-bas':47 'treelit':1,3,15,41 'treelite-runtim':40 'version':26 'x':38","created_at":"2026-04-27T17:05:23.743291+00:00","updated_at":"2026-04-27T17:05:23.743291+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.9.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/dmlc/treelite","docs":null,"changelog":null,"pypi":"https://pypi.org/project/treelite-runtime/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}