Skip to content

Commit 2428d67

Browse files
committed
Add a fallback to hipMalloc() and print warning once when managed memory is not supported.
1 parent 6fab0d4 commit 2428d67

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ggml/src/ggml-cuda/ggml-cuda.cu

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ static cudaError_t ggml_cuda_device_malloc(void ** ptr, size_t size, int device)
104104
if (err == hipSuccess) {
105105
CUDA_CHECK(cudaMemAdvise(*ptr, size, hipMemAdviseSetCoarseGrain, device));
106106
}
107+
108+
// fall back to cudaMalloc if not supported (e.g. on Windows)
109+
if (err == hipErrorNotSupported) {
110+
static bool warnedUnsupported = false;
111+
if (!warnedUnsupported) {
112+
GGML_LOG_WARN("hipMallocManaged unsupported, falling back to hipMalloc.\n");
113+
warnedUnsupported = true;
114+
}
115+
116+
err = cudaMalloc(ptr, size);
117+
}
107118
#endif // defined(GGML_USE_HIP)
108119
}
109120
else

0 commit comments

Comments
 (0)