diff --git a/c10/cuda/CUDAFunctions.cpp b/c10/cuda/CUDAFunctions.cpp index 683ed9b76845..9839e4e72049 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,