0016-temporary-prevent-rocm-cuda-mixed-loading.patch 1.3 KB
Newer Older
Daniel Hiltgen's avatar
Daniel Hiltgen committed
1
2
3
4
5
6
7
8
9
10
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Hiltgen <daniel@ollama.com>
Date: Sun, 22 Jun 2025 09:22:05 -0700
Subject: [PATCH] temporary prevent rocm+cuda mixed loading

---
 ggml/src/ggml-backend-reg.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/ggml/src/ggml-backend-reg.cpp b/ggml/src/ggml-backend-reg.cpp
11
index 3040b2aa..f1e9c180 100644
Daniel Hiltgen's avatar
Daniel Hiltgen committed
12
13
--- a/ggml/src/ggml-backend-reg.cpp
+++ b/ggml/src/ggml-backend-reg.cpp
14
@@ -581,8 +581,16 @@ void ggml_backend_load_all_from_path(const char * dir_path) {
Daniel Hiltgen's avatar
Daniel Hiltgen committed
15
16
17
18
19
20
21
22
 
     ggml_backend_load_best("blas", silent, dir_path);
     ggml_backend_load_best("cann", silent, dir_path);
-    ggml_backend_load_best("cuda", silent, dir_path);
-    ggml_backend_load_best("hip", silent, dir_path);
+
+    // Avoid mixed hip+cuda configurations
+    const char * hip_devices = std::getenv("HIP_VISIBLE_DEVICES");
23
+    const char * rocr_devices = std::getenv("ROCR_VISIBLE_DEVICES");
Daniel Hiltgen's avatar
Daniel Hiltgen committed
24
25
26
27
28
+    if (!hip_devices && !rocr_devices) {
+        ggml_backend_load_best("cuda", silent, dir_path);
+    } else {
+        ggml_backend_load_best("hip", silent, dir_path);
+    }
29
+
Daniel Hiltgen's avatar
Daniel Hiltgen committed
30
31
     ggml_backend_load_best("metal", silent, dir_path);
     ggml_backend_load_best("rpc", silent, dir_path);
32
     ggml_backend_load_best("sycl", silent, dir_path);