diff --git a/tinygrad/runtime/ops_metal.py b/tinygrad/runtime/ops_metal.py index 4e08d0318f765..2a1a78f9ff68b 100644 --- a/tinygrad/runtime/ops_metal.py +++ b/tinygrad/runtime/ops_metal.py @@ -36,7 +36,6 @@ def __init__(self, device:MetalDevice, name:str, lib:bytes): shader.write(lib) shader.flush() os.system(f"cd {pathlib.Path(__file__).parents[2]}/disassemblers/applegpu && python3 compiler_explorer.py {shader.name}") - assert lib[:4] == b"MTLB", "Invalid Metal library. Could be due to using conda. Try system python or METAL_XCODE=1 DISABLE_COMPILER_CACHE=1." data = libdispatch.dispatch_data_create(lib, len(lib), None, None) self.library = unwrap2(self.device.device.newLibraryWithData_error_(data, None)) self.fxn = self.library.newFunctionWithName_(name) @@ -97,6 +96,9 @@ def __init__(self, device:str): self.mtl_buffers_in_flight: List[Any] = [] self.mv_in_metal: List[memoryview] = [] self.track_cross_buffer: List[Any] = [] + if getenv("CONDA_SHLVL") > 0: + os.environ["METAL_XCODE"] = "1" + print("Using Metal from Xcode SDK due to Conda targeting an unsupported macOS version(11.0).") from tinygrad.runtime.graph.metal import MetalGraphRunner super().__init__(device, MetalAllocator(self), MetalCompiler(None if getenv("METAL_XCODE") else self), functools.partial(MetalProgram, self), MetalGraphRunner)