Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _cudaGetFunctionPointer(name):
global cudaLib
if name in _cudaGetFunctionPointer_cache:
return _cudaGetFunctionPointer_cache[name]
libLoadLock.acquire()
try:
# ensure library was loaded
if (cudaLib == None):
raise NVMLError(NVML_ERROR_UNINITIALIZED)
try:
_cudaGetFunctionPointer_cache[name] = getattr(cudaLib, name)
return _cudaGetFunctionPointer_cache[name]
except AttributeError:
raise NVMLError(NVML_ERROR_FUNCTION_NOT_FOUND)
finally:
# lock is always freed
libLoadLock.release()
def _cudaGetFunctionPointer(name):
global cudaLib
if name in _cudaGetFunctionPointer_cache:
return _cudaGetFunctionPointer_cache[name]
libLoadLock.acquire()
try:
# ensure library was loaded
if (cudaLib == None):
raise NVMLError(NVML_ERROR_UNINITIALIZED)
try:
_cudaGetFunctionPointer_cache[name] = getattr(cudaLib, name)
return _cudaGetFunctionPointer_cache[name]
except AttributeError:
raise NVMLError(NVML_ERROR_FUNCTION_NOT_FOUND)
finally:
# lock is always freed
libLoadLock.release()
def _cudaCheckReturn(ret):
if (ret != NVML_SUCCESS):
raise NVMLError(ret)
return ret
def __new__(typ, value):
'''
Maps value to a proper subclass of NVMLError.
See _extractNVMLErrorsAsClasses function for more details
'''
if typ == NVMLError:
typ = NVMLError._valClassMapping.get(value, typ)
obj = Exception.__new__(typ)
obj.value = value
return obj