do not cache peer access status
@@ -19,7 +19,6 @@ cdef object _thread_local = threading.local()
cdef dict _devices = {}
cdef dict _compute_capabilities = {}
-cdef dict _peer_access_checked = {}
cdef class _ThreadLocalStack:
@@ -96,26 +95,18 @@ cdef bint _enable_peer_access(int device, int peer) except -1:
if device == peer:
return True
- device_pair = device, peer
-
- if device_pair in _peer_access_checked:
- return _peer_access_checked[device_pair]
cdef int can_access = runtime.deviceCanAccessPeer(device, peer)
if can_access == 0:
- _peer_access_checked[device_pair] = False
return False
cdef int current = runtime.getDevice()
runtime.setDevice(device)
try:
- runtime.deviceEnablePeerAccess(peer)
- except runtime_module.CUDARuntimeError as e:
- # peer access could already be set by external libraries at this point
- if e.status != runtime.errorPeerAccessAlreadyEnabled:
- raise
+ # Note: external libraries may disable the peer access, so we need to
+ # call this everytime. See #5496.
+ runtime._deviceEnsurePeerAccess(peer)
finally:
runtime.setDevice(current)
- _peer_access_checked[device_pair] = True
return True
