From a04320ba3147724a0b39c85d29e67760fc1b58c4 Mon Sep 17 00:00:00 2001 From: Pawel Stopinski Date: Mon, 29 May 2023 08:37:27 +0200 Subject: [PATCH] Disables cudaMemPrefetchAsync() in unsupported systems (e.g. Windows). Fixes artidoro/qlora#73 and TimDettmers/bitsandbytes#453 (cherry picked from commit e02f078000ed19fe57321c464dd16d60f18d6803) --- csrc/pythonInterface.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/csrc/pythonInterface.c b/csrc/pythonInterface.c index 23a0364cc..57f60f598 100644 --- a/csrc/pythonInterface.c +++ b/csrc/pythonInterface.c @@ -356,6 +356,10 @@ extern "C" void cprefetch(void *ptr, size_t bytes, int device) { + int hasPrefetch = 0; + CUDA_CHECK_RETURN(cudaDeviceGetAttribute(&hasPrefetch, cudaDevAttrConcurrentManagedAccess, device)); // 40ns overhead + if (hasPrefetch == 0) return; + CUDA_CHECK_RETURN(cudaMemPrefetchAsync(ptr, bytes, device, 0)); CUDA_CHECK_RETURN(cudaPeekAtLastError()); }