[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
This commit is contained in:
Nikita Shulga
2025-09-09 04:12:10 +00:00
committed by PyTorch MergeBot
parent 065c446193
commit 847d7f21af

View File

@ -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,