From 847d7f21af18ed51fe96f7054191b4a36f90254c Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Tue, 9 Sep 2025 04:12:10 +0000 Subject: [PATCH] [CUDA-13] Implement workaround for cudaErrorNotSupported (#162412) See https://github.com/pytorch/pytorch/issues/162333#issuecomment-3267929585 Pull Request resolved: https://github.com/pytorch/pytorch/pull/162412 Approved by: https://github.com/eqy, https://github.com/atalman --- c10/cuda/CUDAFunctions.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/c10/cuda/CUDAFunctions.cpp b/c10/cuda/CUDAFunctions.cpp index 683ed9b7684..9839e4e7204 100644 --- a/c10/cuda/CUDAFunctions.cpp +++ b/c10/cuda/CUDAFunctions.cpp @@ -78,6 +78,18 @@ int device_count_impl(bool fail_if_no_driver) { "would like to use GPUs, turn off ASAN."); break; #endif // C10_ASAN_ENABLED +#if _WIN32 && CUDA_VERSION >= 13000 + // Workaround for CUDA-13.0 error handling on Windows, see + // https://github.com/pytorch/pytorch/issues/162333#issuecomment-3267929585 + case cudaErrorNotSupported: + if (!fail_if_no_driver) { + TORCH_WARN( + "cudaGetDeviceCount() returned cudaErrorNotSupported, " + "likely using older driver or on CPU machine"); + count = 0; + break; + } +#endif default: TORCH_CHECK( false,