[PR #9024] [MERGED] fix: harden backend loading #59533

Closed
opened 2026-04-29 14:27:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/9024
Author: @mxyng
Created: 2/11/2025
Status: Merged
Merged: 2/11/2025
Merged by: @mxyng

Base: mainHead: mxyng/ggml-path


📝 Commits (2)

  • add51f7 wrap ggml_backend_load_best in try/catch
  • 67ba33c ignore non-ollama paths

📊 Changes

3 files changed (+97 additions, -22 deletions)

View changed files

llama/patches/0017-try-catch-backend-load.patch (+69 -0)
📝 ml/backend/ggml/ggml/src/ggml-backend-reg.cpp (+23 -22)
📝 ml/backend/ggml/ggml/src/ggml.go (+5 -0)

📄 Description

  • wrap ggml_backend_load_best in try/catch to mitigate potential system level exceptions (such as permissions)1 2
  • expose some of the log messages in ggml_backend_load_best which should help debugging
  • only try loading from known library paths
    • known paths include the executable directory or any directories which contains lib/ollama on Linux/macOS and lib\ollama on Windows
    • this handles dev cases since the search path is build/lib/ollama

Related to #9014
Related to #8926


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/9024 **Author:** [@mxyng](https://github.com/mxyng) **Created:** 2/11/2025 **Status:** ✅ Merged **Merged:** 2/11/2025 **Merged by:** [@mxyng](https://github.com/mxyng) **Base:** `main` ← **Head:** `mxyng/ggml-path` --- ### 📝 Commits (2) - [`add51f7`](https://github.com/ollama/ollama/commit/add51f7ee337ea24e8635551187cf649f216ff46) wrap ggml_backend_load_best in try/catch - [`67ba33c`](https://github.com/ollama/ollama/commit/67ba33c761dcb61ef6b5d47ba42b7245c55c6cfd) ignore non-ollama paths ### 📊 Changes **3 files changed** (+97 additions, -22 deletions) <details> <summary>View changed files</summary> ➕ `llama/patches/0017-try-catch-backend-load.patch` (+69 -0) 📝 `ml/backend/ggml/ggml/src/ggml-backend-reg.cpp` (+23 -22) 📝 `ml/backend/ggml/ggml/src/ggml.go` (+5 -0) </details> ### 📄 Description - wrap ggml_backend_load_best in try/catch to mitigate potential system level exceptions (such as permissions)[1] [2] - expose some of the log messages in ggml_backend_load_best which should help debugging - only try loading from known library paths - known paths include the executable directory or any directories which contains `lib/ollama` on Linux/macOS and `lib\ollama` on Windows - this handles dev cases since the search path is `build/lib/ollama` [1]: https://stackoverflow.com/questions/66559208/stdfilesystem-recursive-iterator-will-throw-permission-denied-even-when-skip-p [2]: https://developercommunity.visualstudio.com/t/c17-stdfilesystemrecursive-directory-iterator-oper-1/875270 Related to #9014 Related to #8926 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-29 14:27:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#59533