diff --git a/tinygrad/runtime/ops_metal.py b/tinygrad/runtime/ops_metal.py index a15ff8ed59..e7185b69e3 100644 --- a/tinygrad/runtime/ops_metal.py +++ b/tinygrad/runtime/ops_metal.py @@ -135,7 +135,8 @@ class MetalAllocator(LRUAllocator): super().__init__() def _alloc(self, size:int, options) -> MetalBuffer: # Buffer is explicitly released in _free() rather than garbage collected via reference count - ret = msg(self.dev.sysdevice, "newBufferWithLength:options:", size, MTLResourceOptions.MTLResourceStorageModeShared, restype=objc_id) + ret = msg(self.dev.sysdevice, "newBufferWithLength:options:", ctypes.c_ulong(size), MTLResourceOptions.MTLResourceStorageModeShared, + restype=objc_id) if ret.value is None: raise MemoryError(f"Metal OOM while allocating {size=}") return MetalBuffer(ret, size) def _free(self, opaque:MetalBuffer, options): msg(opaque.buf, "release")