diff --git a/tinygrad/runtime/ops_nv.py b/tinygrad/runtime/ops_nv.py index eb48caf39b..b04f804158 100644 --- a/tinygrad/runtime/ops_nv.py +++ b/tinygrad/runtime/ops_nv.py @@ -86,7 +86,9 @@ class NVCompiler(Compiler): class HWQueue: def __init__(self): self.q, self.binded_device, self.next_cmd_index = [], None, 0 def __del__(self): - if self.binded_device is not None: self.binded_device._gpu_free(self.hw_page) + if self.binded_device is not None: + self.binded_device.synchronize() # Synchronize to ensure the buffer is no longer in use. + self.binded_device._gpu_free(self.hw_page) def ptr(self) -> int: return self.next_cmd_index