mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-09-01 23:46:06 +00:00
no exceptions in __del__ when module creation is failed in hip/cuda (#3107)
This commit is contained in:
@@ -50,7 +50,7 @@ class CUDAProgram:
|
||||
self.prg = prg if not CUDACPU else lib
|
||||
|
||||
def __del__(self):
|
||||
if not CUDACPU: check(cuda.cuModuleUnload(self.module))
|
||||
if hasattr(self, 'module'): check(cuda.cuModuleUnload(self.module))
|
||||
|
||||
def __call__(self, *bufs, global_size:Tuple[int,int,int], local_size:Tuple[int,int,int], vals:Tuple[int, ...]=(), wait=False):
|
||||
if not CUDACPU: check(cuda.cuCtxSetCurrent(self.device.context))
|
||||
|
||||
@@ -33,7 +33,7 @@ class HIPProgram:
|
||||
self.prg = init_c_var(hip.hipFunction_t(), lambda x: check(hip.hipModuleGetFunction(ctypes.byref(x), self.module, name.encode("utf-8"))))
|
||||
|
||||
def __del__(self):
|
||||
if not MOCKHIP: check(hip.hipModuleUnload(self.module))
|
||||
if hasattr(self, 'module'): check(hip.hipModuleUnload(self.module))
|
||||
|
||||
def __call__(self, *args, global_size:Tuple[int,int,int], local_size:Tuple[int,int,int], vals:Tuple[int, ...]=(), wait=False):
|
||||
if MOCKHIP: return float("inf")
|
||||
|
||||
Reference in New Issue
Block a user