Skip to content

Commit 9e9b4c8

Browse files
authored
Adds defensive code in device _get_attribute to gracefully handle queries against older drivers. (#1409)
1 parent da7eb1f commit 9e9b4c8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cuda_core/cuda/core/_device.pyx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ cdef class DeviceProperties:
5858
cdef inline _get_attribute(self, cydriver.CUdevice_attribute attr):
5959
"""Retrieve the attribute value directly from the driver."""
6060
cdef int val
61+
cdef cydriver.CUresult err
6162
with nogil:
62-
HANDLE_RETURN(cydriver.cuDeviceGetAttribute(&val, attr, self._handle))
63+
err = cydriver.cuDeviceGetAttribute(&val, attr, self._handle)
64+
if err == cydriver.CUresult.CUDA_ERROR_INVALID_VALUE:
65+
return 0
66+
HANDLE_RETURN(err)
6367
return val
6468

6569
cdef _get_cached_attribute(self, attr):

0 commit comments

Comments
 (0)