Checking an ONNX Runtime load failure
Did you start the server and it fails at the model loading stage? Bareun uses the ONNX Runtime for morphological analysis, so it cannot start if the runtime library path (libPath) or the execution provider setting is off.
Let's check them one by one with this document.
Symptoms
- During server startup, it exits with an error saying it cannot find or load the ONNX Runtime library.
- It fails at the session creation stage for
seg-model.onnx/tag-model.onnx. - You see an execution provider (for example, CUDA/CoreML) initialization error.
Cause
Bareun finds and loads the ONNX Runtime dynamic library from the libPath path, and on top of it creates sessions for seg-model.onnx (segmentation) and tag-model.onnx (POS tagging). It fails if any of the following is off.
| Cause | Description |
|---|---|
Wrong libPath | The location of the ONNX Runtime library is wrong |
| Missing library | The platform-specific ONNX Runtime file is not in the package |
executionProvider mismatch | A provider that the environment does not support is specified |
| Wrong model path | modelPath does not point to where the server stores downloaded models |
It can be normal that the model files are not there yet
Bareun does not include models in the installation files and downloads them on first run. So it is normal for the area under modelPath to be empty right after installation. If startup stopped because the models could not be downloaded, see When the model cannot be downloaded on first startup.
This document covers the case where the models are in place but it fails on the ONNX Runtime side.
Solution
-
Check
libPath. ThelibPathinbareun.jsonpoints to the directory that holds the ONNX Runtime library. The default is usually${BAREUN_ROOT}/lib, a value you do not need to change. If you changed it, check that it matches the actual library location.{ "libPath": "${BAREUN_ROOT}/lib", "modelPath": "${BAREUN_ROOT}/var/models", "executionProvider": { "provider": "cpu" } } -
Check that the library is really there. The platform-specific ONNX Runtime file must be under
libPath. If the installation package is broken or only partly copied, install again. -
Match
executionProviderto your environment. If it is not a GPU environment, leaving it ascpuis safest. If you setgpubut the driver and runtime are not in place, initialization can fail. -
Check the model path. Check that
seg-model.onnxandtag-model.onnxare undermodelPath(default${BAREUN_ROOT}/var/models). If it is empty, they have not been downloaded yet, so first see When the model cannot be downloaded on first startup. If you changed the path arbitrarily, make it match where the server stores downloaded models.
Beware of typos in the config file
bareun.json is JSON that the server reads as is. If there is a typo in a key name or path, the server does not work. Get in the habit of backing up the original before editing.
Prevention and tips
- First set
executionProvidertocpuand check that the server starts normally, then apply the GPU settings step by step. This makes it easier to narrow down the cause. - For automatic switching from GPU to CPU, see When GPU execution falls back to CPU, and for CUDA version problems, see CUDA/cuDNN version mismatch.
Frequently asked questions
Q. What usually causes an ONNX Runtime load failure?
The most common causes are that the ONNX Runtime library is not at the location libPath points to, or that you specified an executionProvider the environment does not support. A failure because the model files (seg-model.onnx, tag-model.onnx) are not there yet is usually the first-startup download not having finished, so see When the model cannot be downloaded on first startup.
Q. How should I set libPath?
The libPath in bareun.json points to the ONNX Runtime library directory, and you can use the default (usually ${BAREUN_ROOT}/lib) as it is. If you moved it arbitrarily, make it match the actual library location.
Q. It fails at model session creation. What should I look at?
Check that both seg-model.onnx (segmentation) and tag-model.onnx (POS tagging) are under modelPath (default ${BAREUN_ROOT}/var/models). Models are not in the installation files and are downloaded on first startup, so if the files are missing, you should check whether the download finished instead of reinstalling.
See When the model cannot be downloaded on first startup.
Q. I get an execution provider initialization error such as CUDA or CoreML.
It happens when you specify an executionProvider that the environment does not support. First set it to cpu and check that the server starts, then apply the GPU settings step by step. For GPU falling back to CPU, see
GPU fallback, and for version problems, see CUDA/cuDNN version mismatch.