diff --git a/tinygrad/runtime/ops_disk.py b/tinygrad/runtime/ops_disk.py index 56809dafbc..5f1dc144c4 100644 --- a/tinygrad/runtime/ops_disk.py +++ b/tinygrad/runtime/ops_disk.py @@ -41,7 +41,9 @@ class DiskDevice(Compiled): if self.count == 0: if self.fd is not None: os.close(self.fd) - if hasattr(self, "mem"): self.mem.close() + if hasattr(self, "mem"): + try: self.mem.close() + except BufferError: pass self.size = None def _iouring_setup(self): DiskDevice._tried_io_uring_init = True