]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
CUDA: require explicit opt-in for P2P access (llama/21910)
authorJohannes Gäßler <redacted>
Wed, 15 Apr 2026 14:01:46 +0000 (16:01 +0200)
committerGeorgi Gerganov <redacted>
Thu, 30 Apr 2026 08:29:10 +0000 (11:29 +0300)
ggml/src/ggml-cuda/ggml-cuda.cu

index 5d81befec321e26dcc7400615c9d20cf0953bab4..c17db3875adac8675016b7c38e0c0b168efc7c52 100644 (file)
@@ -324,16 +324,18 @@ static ggml_cuda_device_info ggml_cuda_init() {
     // configure logging to stdout
     // CUBLAS_CHECK(cublasLoggerConfigure(1, 1, 0, nullptr));
 
-    for (int id = 0; id < info.device_count; ++id) {
-        ggml_cuda_set_device(id);
-        for (int id_other = 0; id_other < info.device_count; ++id_other) {
-            if (id == id_other) {
-                continue;
-            }
-            int can_access_peer;
-            CUDA_CHECK(cudaDeviceCanAccessPeer(&can_access_peer, id, id_other));
-            if (can_access_peer) {
-                CUDA_CHECK(cudaDeviceEnablePeerAccess(id_other, 0));
+    if (getenv("GGML_CUDA_P2P") != nullptr) {
+        for (int id = 0; id < info.device_count; ++id) {
+            ggml_cuda_set_device(id);
+            for (int id_other = 0; id_other < info.device_count; ++id_other) {
+                if (id == id_other) {
+                    continue;
+                }
+                int can_access_peer;
+                CUDA_CHECK(cudaDeviceCanAccessPeer(&can_access_peer, id, id_other));
+                if (can_access_peer) {
+                    CUDA_CHECK(cudaDeviceEnablePeerAccess(id_other, 0));
+                }
             }
         }
     }