Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

return an error when the model cant be loaded

Bruce MacDonald55ab5e60dbb0
diff --git a/ollama/engine.py b/ollama/engine.py
index 39a60da94..b45dcd6df 100644
--- a/ollama/engine.py
+++ b/ollama/engine.py
@@ -45,11 +45,14 @@ def load(model, models_home=".", llms={}):
# try loading this as a path to a model, rather than a model name
model_path = os.path.abspath(model)
- # suppress LLM's output
- with suppress_stderr():
- llm = LLM(model_path, verbose=False)
- llms.update({model: llm})
-
+ try:
+ # suppress LLM's output
+ with suppress_stderr():
+ llm = LLM(model_path, verbose=False)
+ llms.update({model: llm})
+ except Exception as e:
+ # e is sent to devnull, so create a generic exception
+ raise Exception(f"Failed to load model: {model}")
return llm